Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

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.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

Data Binding in user control

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 01-10-2006   #1 (permalink)
Griff
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 SpecsSystem Spec
Old 01-10-2006   #2 (permalink)
Griff
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 SpecsSystem Spec
Old 01-10-2006   #3 (permalink)
Jason Dolinger
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 SpecsSystem Spec
Old 01-10-2006   #4 (permalink)
Rob Relyea [MSFT]
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 SpecsSystem Spec
Closed Thread

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


Vistax64.com 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 2005-2008

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 47 48 49 50 51