![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks. |
| |||||||
| |
| | #1 (permalink) |
| | 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) |
| | 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) |
| | 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) |
| | 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 | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| User Account Control & Data in the Program Files Folder | Vista account administration | |||