Binding issue

1 posts, 0 answers
  1. Gopinath
    Gopinath avatar
    63 posts
    Member since:
    Sep 2011

    Posted 11 Apr 2012 Link to this post


    I have created a user control (name: AuthTextBox) with Textbox and have created dependency property for Text as shown below.

    public string Text
                    return (string)GetValue(TextProperty);
                    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.

Back to Top