I have user control:
public class TestTextBox : TextBox { public TestTextBox() { Text = "ctor text"; } }
And xaml that uses this control:
<StackPanel Orientation="Vertical"> <controls:TestTextBox Text="xaml text"/> <ItemsControl> <ItemsControl.ItemTemplate> <DataTemplate> <controls:TestTextBox Text="xaml text"/> </DataTemplate> </ItemsControl.ItemTemplate> <System:String>111</System:String> </ItemsControl> <StackPanel>
As a result, TestTextBox.Text is different in this case - "xaml text" in the first case, "ctor text" in the second case.
Can someone explain why it works this way? I expect TestTextBox.Text to be "xaml text" in both cases.
source share