I have some idea but I can't make this happened. I have some TextBox in my wpf
<Button Content="Add" Command="{Binding AddAdditionalFileCommand}" Name="MB" />
<TextBox Text="{Binding SomeModel.File.FileName}" />
and in my vm
FileName = Path.GetFileName(file)
This textbox show the name of the loaded file with extension. And I can change this name of file. Ok. And my idea is when I click button to upload the file and after uploading file when in textbox appears the name of the file I want to focus automatically to this all name of file in textbox without extension. Can I do that something like this?
For instance Upload the file named test.mpkg and focus on test without mpkg. Like in Windows when you want to rename the file. It focus on file name without extension.
Edit My command in ViewModel
private DelegateCommand addAdditionalFileCommand;
public DelegateCommand AddAdditionalFileCommand
{
get
{
if (addAdditionalFileCommand == null)
addAdditionalFileCommand = new DelegateCommand(x =>
{
var file = IOService.OpenFileDialog("", new string[] { "File|*.*" });
if (System.IO.File.Exists(file))
{
Model.Package = new ApplicationVersionPackage() {
FilePack = File.ReadAllBytes(file),
FileName = Path.GetFileName(file)
};
}
});
return addAdditionalFileCommand;
}
set
{
if (addAdditionalFileCommand != value)
{
addAdditionalFileCommand = value;
NotifyPropertyChanged("AddAdditionalFileCommand");
}
}
}
How pass this Select or Focus from name of textbox to this command