Question: 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?

Answer: 
You can try the following:

```
<TextBox Text="{Binding Path=., UpdateSourceTrigger=PropertyChanged}"></TextBox>

```
You can bind directly to TextBox.
What is the point to bind to StackPanel if InputFile is string?

```
<StackPanel Orientation="Horizontal">
    <TextBox Text="{Binding InputFile}"></TextBox>
</StackPanel>

```

**Edit:**

You can bind command by using [FindAncestor](https://stackoverflow.com/a/1127964/667792 "FindAncestor"):

```
Command="{Binding RelativeSource={RelativeSource FindAncestor, 
AncestorType={x:Type Window}}, Path=DataContext.Select}"

```

Alternatively you can create custom type similar to this one:

```
public class InputFileViewModel
{
  string File {get; set;}
  ICommant Select {get; set;}
}

```

And then bind in TextBox to File property.