![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | Expose properties of "sub controls" in control template 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 is whenever someone clicks the button on the menu item, I'd like to read the value from the text box beside it and apply it to the mediaelement in the listbox, so I could change the video on demand. Obviosuly, this requires working from the top level of the heirarchy. The problem I'm having is that I can get all kinds of messages, like whether the text box has changed, or the button has been pressed, in the top level of the heirarchy, but it seems fairly difficult to actually read the text boxe's value from the top level. Specifically, the path of access (programmtically in C#) isn't very clear. What I'd likie to do is e |
My System Specs![]() |
| | #2 (permalink) |
| | Re: Expose properties of "sub controls" in control template Your message cut off, so I am not 100% sure what you are trying to do. But, see if this gets close: 1) In code you can attach an event handler to each button on the menu of each list item. 2) The handler for this can use the source argument to locate the button that was pressed and obtain its content to get to the text within the button. Or, get is parent then get the children to get to the text, etc. 3) If you place the control template as a window resource, you may be able to attach the events to methods on the window code behind in XAML. You need to play with there you declare the template and what object it will attach the handler method to. There are several places you can declare the template (window resource, style resource, inline definition on an enclosing element with a type as the name, etc). 4) You can bind from the text element to an attached property on the button as well to remove the navigation from the code, but you will need to create the attached property in code. Michael "Matt Mitchell" <MattMitchell@discussions.microsoft.com> wrote in message news:7C20A777-1398-4588-8FE3-4579AFB4EE10@microsoft.com... > 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 is whenever someone > clicks the button on the menu item, I'd like to read the value from the > text > box beside it and apply it to the mediaelement in the listbox, so I could > change the video on demand. > > Obviosuly, this requires working from the top level of the heirarchy. The > problem I'm having is that I can get all kinds of messages, like whether > the > text box has changed, or the button has been pressed, in the top level of > the > heirarchy, but it seems fairly difficult to actually read the text boxe's > value from the top level. Specifically, the path of access > (programmtically > in C#) isn't very clear. > > What I'd likie to do is e |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Expose properties of "sub controls" in control template Actually, you can use Control.Template.FindName(String name, FrameworkElement templatedParent) method to Find the element under a specified ControlTemplate, you should specify the name parameter which is associated with the id of the element to be found, and a templatedParent parameter which is associated with the parent which has this ControlTemplate as its Template, after you find the wanted element, you can do any thing meaningful with this element, for instance, changing the properties of this element etc etc. Hope this helps ----- Original Message ----- From: "Matt Mitchell" <MattMitchell@discussions.microsoft.com> Newsgroups: microsoft.public.windows.developer.winfx.avalon Sent: Tuesday, February 14, 2006 1:15 AM Subject: Expose properties of "sub controls" in control template > 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 is whenever someone > clicks the button on the menu item, I'd like to read the value from the > text > box beside it and apply it to the mediaelement in the listbox, so I could > change the video on demand. > > Obviosuly, this requires working from the top level of the heirarchy. The > problem I'm having is that I can get all kinds of messages, like whether > the > text box has changed, or the button has been pressed, in the top level of > the > heirarchy, but it seems fairly difficult to actually read the text boxe's > value from the top level. Specifically, the path of access > (programmtically > in C#) isn't very clear. > > What I'd likie to do is e |
My System Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Build a VM as "Template" | Virtual Server | |||
| Create your own template then have it there to pick from in "customize this folder" in explorer? | Vista file management | |||
| Vista not wotking with "My Computer" or "Control Panel", "Screen Saver" | Vista General | |||
| Cannot access properties in "local area connection properties" win | Vista networking & sharing | |||
| Windows Explorer: How to force ALL folders to use "All Items" template rather than "Pictures & Videos" | Vista General | |||