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 - Updated (aciddently hit post before) Exposing properties of subcon

 
 
Old 02-14-2006   #1 (permalink)
Matt Mitchell


 
 

Updated (aciddently hit post before) Exposing properties of subcon

So, I'm playing around with XAML and EID, and although I'm not sure whether I
completely understand the concepts yet, I have a question.

So I'm creating a control template. This specific control template is for a
button, and I put a menu in it, and on the menu I made another control
template for the menu item, which noiw has a text box and a button on it.
Pretty useles, but I'm trying to get a feel for the limitations of the system.

Now, on the form, I also have another templated control, a ListBox where I
added a MediaElement in the background, so that it plays a movie behind the
list box items. Again, fairly useless, but it looks cool.

So, in my useless appplication, what I'd like to do it whenever someone
clicks the button on the menu item, read the value from the text box and
update the value of the MediaElement's source, programattically.

The problem is that the path of access to the subcontrols of the control
template isn't clear at all from the top level of the applicatiion. I have
no idea how to get the value. Is it possible to expose the properties of a
subcontrol on a control template to the top level? So I could read the value
of the text box like a value of the button.

Or, what is the best way to do this, barring data binding.

My System SpecsSystem Spec
Old 02-14-2006   #2 (permalink)
MueMeister


 
 

Re: Updated (aciddently hit post before) Exposing properties of subcon

Hey Matt,

> The problem is that the path of access to the subcontrols of the control
> template isn't clear at all from the top level of the applicatiion. I have
> no idea how to get the value. Is it possible to expose the properties of a
> subcontrol on a control template to the top level? So I could read the value
> of the text box like a value of the button.


Attached Properties allow you to inherit values of properties:
http://blogs.msdn.com/nickkramer/sea...q=attached&p=1

In decmber CTP (and I think in january CTP, too) it was not possible to
reference elements within a template control's visual tree directly.
There is a way to retrive elements within such a template through
myButton.Template.FindName("myNestedMenu", myButton) from code. Try to
set the binding from code then.

> Or, what is the best way to do this, barring data binding.


Probably you know that you can react on ChangeNotifications manually and
care about sync by yourself. This would be one way I think.

Chris
My System SpecsSystem Spec
 

Thread Tools



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