Databinding in UserControl [modified]
-
I'm stuck (as usual). A have a user control with 6 textboxes. But to make it easier, I'm trying to break down the problem a bit and lets say there is one textbox. USERCONTROL1.XAML:CS
public partial class AttenuationBox : UserControl
{
private String justAtest;
public String ATest { get { return justATest; } set { ...public String LowChRx { get { return tbLowChRX.Text; } set { tbLowChRX.Text = value; } }
...
}USERCONTROL1.XAML
<textbox name="tbLowChRX" text="{Binding Path=ATest}"></textbox>
Now I want tbLowChRX to be bound to justAtest. But just can't get it to work. Must be something I have missed in Source or Path or...
modified on Sunday, April 19, 2009 12:49 PM
-
I'm stuck (as usual). A have a user control with 6 textboxes. But to make it easier, I'm trying to break down the problem a bit and lets say there is one textbox. USERCONTROL1.XAML:CS
public partial class AttenuationBox : UserControl
{
private String justAtest;
public String ATest { get { return justATest; } set { ...public String LowChRx { get { return tbLowChRX.Text; } set { tbLowChRX.Text = value; } }
...
}USERCONTROL1.XAML
<textbox name="tbLowChRX" text="{Binding Path=ATest}"></textbox>
Now I want tbLowChRX to be bound to justAtest. But just can't get it to work. Must be something I have missed in Source or Path or...
modified on Sunday, April 19, 2009 12:49 PM
You will need to make sure the source is right on the binding. Here's a simple example of one way to do it: WPF: Binding to Properties in your UserControl or Window[^] I'm not sure why you'd want to bind directly to the field, nor do I think you can, but you should be able to bind to the ATest property. Of course, for change notifications when the property is updated, you may want to make that a dependency property. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
You will need to make sure the source is right on the binding. Here's a simple example of one way to do it: WPF: Binding to Properties in your UserControl or Window[^] I'm not sure why you'd want to bind directly to the field, nor do I think you can, but you should be able to bind to the ATest property. Of course, for change notifications when the property is updated, you may want to make that a dependency property. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Then that example at the link works... :)
Mark Salsbery Microsoft MVP - Visual C++ :java: