This is a migrated thread and some comments may be shown as answers.

Binding issue

0 Answers 52 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Gopinath
Top achievements
Rank 2
Gopinath asked on 11 Apr 2012, 10:44 AM
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
Tags
General Discussions
Asked by
Gopinath
Top achievements
Rank 2
Share this question
or