I have two textboxes, the first of them I've bound to a tabControl's Item's Header. I did it in the code behind.
The problem is that the binding succeeds only in the first time.
XAML:
<StackPanel>
<TabControl x:Name="tabcontrol">
<TabControl.Items>
<TabItem>
</TabItem>
</TabControl.Items>
</TabControl>
<TextBox Text="5" x:Name="txtbox"></TextBox>
<TextBox Text="dsfdf"></TextBox>
</StackPanel>
Code Behind:
public partial class Window4 : Window
{
public Window4()
{
InitializeComponent();
var b = new Binding { Mode = BindingMode.OneWay, Source = txtbox.Text };
((TabItem)tabcontrol.Items[0]).SetBinding(HeaderedContentControl.HeaderProperty, b);
}
}