In my application, I have the following TabControl:
<TabControl ItemsSource="{Binding MyItemsSource}"
ContentTemplate="{StaticResource ResourceKey=MyContentTemplate}"
IsSynchronizedWithCurrentItem="True" />
Here is the ContentTemplate used:
<DataTemplate x:Key="MyContentTemplate">
<Canvas>
<TextBox Text="{Binding Path=MyFirstText, Mode=TwoWay}" />
<TextBox Text="{Binding Path=MySecondText, Mode=TwoWay}" />
</Canvas>
</DataTemplate>
And the ItemsSource:
public ObservableCollection<MyData> MyItemsSource { get; set; }
public class MyData
{
public string MyFirstText { get; set; }
public string MySecondText { get; set; }
}
Please consider this scenario:
- Select the first tab
- Enter some text in the first TextBox
- Select the second tab
- Select the first tab: The text entered in the TextBox of the first tab disappeared (because the binding was not applied)
Another scenario:
- Select the first tab
- Enter some text in the first TextBox
- Select the second TextBox (or whatever to change the focus except changing tab)
- Select the second tab
- Select the first tab: The text entered is still displayed (because the binding was applied)
Is that a normal behavior? Or am I doing something wrong? Thank you.