Hi,
I have a problem if any one can help me to solve it, the problem is.
i have a user control it is Rounded Text Box,composed from one text box only,
i did write some line of code to can bind this user control,it is worked but in one way if i change the source property the rounded text box show the modification by if i change from the text box the change do not appear in property bounded;
the code behind of rounded text box is :
public partial class UCRTextBox : UserControl
{
public static readonly DependencyProperty TextProperty = DependencyProperty.Register
("Text",typeof(string),typof(UCRTextBox), new FrameworkPropertyMetadata
(null,FrameworkMetadataOptions.BindsTwoWayByDefault, new PropertyChangedCallBach(textChangedCallBack),
new CoerceValueCallback(coerceValue)));
public string Text
{
get{return (string)GetValue(TextProperty);}
set{SetValue(TextProperty,value);}
}
static void textChangedCallBack(DependencyObject property,DependencyPropertyChangedEventsArgs args)
{
UCRTextBox ucRounded=(UCRTextBox)property;
ucRounded.TextBx.text=(string)args.NewValue;
}
static object CoerceValue(DependencyObject sender,object value)
{
return (string)value;
}
}
and the code in the window with i did use this control i did bind it by code behind:
private void SetTextBoxBinding(FrameworkElement target,DependencyProperty dp,string value)
{
Binding b=new Binding(value);
b.source=_editPatient.Patient;
b.Mode=BindingMode.TwoWay;
target.SetBinding(dp,binding);
}
Using for this function is :
on the windowLoad Events
this.SetTextbinding(this.txtFirstName,TextBox.TextProperty,"FirstName");
that is all .
can any one show me the correct way to solve this problem??
and thx for all