Binding "Text-Property" of a derived textbox to another textbox doesn´t work
Posted
by Jehof
on Stack Overflow
See other posts from Stack Overflow
or by Jehof
Published on 2010-03-17T14:29:43Z
Indexed on
2010/03/17
14:31 UTC
Read the original article
Hit count: 989
silverlight-4.0
|binding
Hello,
i have a class 'MyTextBox' that derives from the default TextBox in Silverlight. This class currently contains no additional code.
I set up a binding in xaml to bind the Text-Property of MyTextbox to another Textbox to reflect the input made in the Textbox. The effect is that MyTextBox doesn´t update and not display the text of the other Textbox.
Additional i made an equal binding for a normal Textbox. And this works.
Here´s the XAML for the bindings.
<UserControl x:Class="Silverlight.Sample.Dummy"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:my="clr-namespace:Sample"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<StackPanel x:Name="LayoutRoot" Background="White">
<TextBox Height="23" x:Name="textBox2" Width="120" />
<TextBox Text="{Binding ElementName=textBox2, Path=Text, Mode=TwoWay}" Width="120" />
<my:NumberTextBox Width="120" Text="{Binding ElementName=textBox2, Path=Text, Mode=OneWay}" />
</StackPanel>
Is there something special to set for binding, when i derive from a control.
PS: I tried a binding to a dummy object with INotifyPropertyChanged and set it as DataContext for the existing Textboxes. This test works as expected and my derived textbox gets updated.
© Stack Overflow or respective owner