I have a simple WPF application. In the code behind I have an InputFile property like this.
public string InputFile
{
get
{
return _inputFile;
}
set
{
_inputFile = value;
OnPropertyChanged("InputFile");
}
}
Inside the XAML I have a StackPanel like this:
<StackPanel Orientation="Horizontal" DataContext="{Binding Path=InputFile}">
<StackPanel.CommandBindings>
<CommandBinding Command="Open"
CanExecute="OpenCanExecute"
Executed="OpenExecuted" />
<CommandBinding Command="Select"
CanExecute="SelectCanExecute"
Executed="SelectExecuted" />
</StackPanel.CommandBindings>
<TextBox Text="{Binding Path=.}"></TextBox>
<Button Command="Select">...</Button>
<Button Command="Open">-></Button>
</StackPanel>
I need to keep the stackpanel datacontext linked to InputFile to allow the commands functions to access it.
Problem: when InputFile changes, the TextBox is updated but if I type a new value in the Textbox the property InputFile is not updated (setter method is not called). Any idea?