Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
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.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - Data Binding in user control

 
 
Old 01-10-2006   #1 (permalink)
Griff


 
 

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 SpecsSystem Spec
Old 01-10-2006   #2 (permalink)
Griff


 
 

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 SpecsSystem Spec
Old 01-10-2006   #3 (permalink)
Jason Dolinger


 
 

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 SpecsSystem Spec
Old 01-10-2006   #4 (permalink)
Rob Relyea [MSFT]


 
 

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 SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
User Account Control & Data in the Program Files Folder Vista account administration


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46