![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Data Binding in user control I can do this - create a Window - define a Dependency property in the code behind the Window - bind this property it to the content of some standard control placed in the Window (Eg a TextBlock which displays a string set in the code behind) So far so good. But when I - create a custom control (MyControl.xaml & MyControl.xaml.cs) - define dependency properties in the code behind the control - use those properties in the markup for the control to define its appearance - deploy the control in a Window (ie call it up as <local:MyControl> ) I don't see values that I initialised in the code behind the control taking effect in the control I'm sure this might be a datacontext issue in my Window, but I don't see how to resolve it given that there are no actual bindings setup in the Window1.xaml itself. Thanks for any general suggestions or blog pointers. -- Griff (trying to make an industrial UI with XAML/WPF/c#) |
My System Specs![]() |
| | #2 (permalink) |
| Guest | RE: Data Binding in user control I have discovered what was going wrong. I was generating my control from the UserControl base class. I could not get any databinding to work. I changed to ContentControl. Now everything works. -- Griff (trying to make an industrial UI with XAML/WPF/c#) "Griff" wrote: > I can do this > - create a Window > - define a Dependency property in the code behind the Window > - bind this property it to the content of some standard control placed in > the Window > (Eg a TextBlock which displays a string set in the code behind) > So far so good. > > But when I > - create a custom control (MyControl.xaml & MyControl.xaml.cs) > - define dependency properties in the code behind the control > - use those properties in the markup for the control to define its appearance > - deploy the control in a Window (ie call it up as <local:MyControl> ) I > don't see values that I initialised in the code behind the control taking > effect in the control > > I'm sure this might be a datacontext issue in my Window, but I don't see how > to resolve it given that there are no actual bindings setup in the > Window1.xaml itself. > > Thanks for any general suggestions or blog pointers. > -- > Griff > (trying to make an industrial UI with XAML/WPF/c#) |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: Data Binding in user control Griff wrote: > I have discovered what was going wrong. > > I was generating my control from the UserControl base class. I could not > get any databinding to work. > I changed to ContentControl. > Now everything works. > > ContentControl, eh...? I'll have to try that now! Can anyone MS people in this ng (Tina, anyone?) explain what the architectural differences are? Thanks, Jason |
My System Specs![]() |
| | #4 (permalink) |
| Guest | Re: Data Binding in user control UserControl may actually become a subclass of content control in a future CTP...if that goes through successfully, there will be no difference to describe. :-) Thanks, Rob Relyea WPF Program Manager http://longhornblogs.com/rrelyea "Jason Dolinger" <jdolinger@lab49.com> wrote in message news:%230FoZezBGHA.984@tk2msftngp13.phx.gbl... > Griff wrote: >> I have discovered what was going wrong. >> >> I was generating my control from the UserControl base class. I could >> not get any databinding to work. >> I changed to ContentControl. >> Now everything works. > > ContentControl, eh...? I'll have to try that now! Can anyone MS people > in this ng (Tina, anyone?) explain what the architectural differences are? > > Thanks, > Jason |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Binding to properties of a user control | Dave | Avalon | 1 | 04-10-2008 08:29 AM |
| User Account Control & Data in the Program Files Folder | Brian T | Vista account administration | 1 | 07-24-2007 12:03 PM |
| Data Binding of user control property | luba | Avalon | 1 | 10-27-2006 12:00 PM |
| data binding | Joerg Engel | Avalon | 1 | 03-22-2006 03:18 AM |
| Data binding with DataGrid | Vijay | Avalon | 1 | 02-21-2006 01:36 PM |