This question is locked. New answers and comments are not allowed.
Hi,
I have created a user control (name: AuthTextBox) with Textbox and have created dependency property for Text as shown below.
public string Text
{
get
{
return (string)GetValue(TextProperty);
}
set
{
SetValue(TextProperty, value);
}
}
// Using a DependencyProperty as the backing store for DisplayMemberPath. This enables animation, styling, binding, etc...
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register("Text", typeof(string), typeof(AuthTextBox), new PropertyMetadata(new PropertyChangedCallback(OnTextPropertyPropertyChanged)));
private static void OnTextPropertyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
//
var AuthTextBox = d as AuthTextBox;
if (AuthTextBox != null)
{
//@@BASELINE: 11.0
// Check for new value to prevent null set
AuthTextBox.txtCntrl.Text = e.NewValue as string ?? string.Empty;
}
}
In my page i am using that as shown below
<authControls:AuthTextBox x:Name="txt1" Text="{Binding Path=d_mc_mi_general_mat_info.SHORT_NAME, Mode=TwoWay}" />
But here Two way binding not working. I don't want to hard code binding mode in the usercontrol. I want the need to be taken from Text as shown above.
Kindly please help me.
Thanks
Gopinath
I have created a user control (name: AuthTextBox) with Textbox and have created dependency property for Text as shown below.
public string Text
{
get
{
return (string)GetValue(TextProperty);
}
set
{
SetValue(TextProperty, value);
}
}
// Using a DependencyProperty as the backing store for DisplayMemberPath. This enables animation, styling, binding, etc...
public static readonly DependencyProperty TextProperty =
DependencyProperty.Register("Text", typeof(string), typeof(AuthTextBox), new PropertyMetadata(new PropertyChangedCallback(OnTextPropertyPropertyChanged)));
private static void OnTextPropertyPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
//
var AuthTextBox = d as AuthTextBox;
if (AuthTextBox != null)
{
//@@BASELINE: 11.0
// Check for new value to prevent null set
AuthTextBox.txtCntrl.Text = e.NewValue as string ?? string.Empty;
}
}
In my page i am using that as shown below
<authControls:AuthTextBox x:Name="txt1" Text="{Binding Path=d_mc_mi_general_mat_info.SHORT_NAME, Mode=TwoWay}" />
But here Two way binding not working. I don't want to hard code binding mode in the usercontrol. I want the need to be taken from Text as shown above.
Kindly please help me.
Thanks
Gopinath