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 - How does a MarkupExtension get to the VisualTree?

 
 
Old 01-18-2008   #1 (permalink)
tbrummel


 
 

How does a MarkupExtension get to the VisualTree?

Does anyone know how markup extensions like RelativeSource get access to the
visual tree in their ProvideValue implementations?

I want to write a markup extension that walks the tree upward until it finds
an element with a specified Name but I don't see how I can get to the tree or
even the element the markup extension is being invoked on (which is inside a
template).

I've got a scenario where I need to bind to an ancestor just like the
RelativeSource markup extension allows but I can't do it based on the Type of
the ancestor, I need to do it based on the Name of the ancestor. This is
because the item binding is in a template that is hosted in one of several
different parent templates -- and they each will have an element with the
proper Name but the types differ.



My System SpecsSystem Spec
Old 04-03-2008   #2 (permalink)
Denis Vuyka


 
 

RE: How does a MarkupExtension get to the VisualTree?

Here's a set of links that will give you some more details on Markup
extensions:

Sample of MarkupExtension taking in a FrameworkElement
http://forums.microsoft.com/MSDN/Sho...72475&SiteID=1

NameReferenceExtension - MarkupExtension to do name references
http://rrelyea.spaces.live.com/Blog/...5FE!2260.entry

ServiceProvider and XAML: type converters and markup extensions
http://rrelyea.spaces.live.com/Blog/...5FE!1652.entry

I would say it will be a challenging task starting walking the
visual/logical tree from a markup extension. But you can try using the
FrameworkElement target as an entry point for your tree traversal.

"tbrummel" wrote:
Quote:

> Does anyone know how markup extensions like RelativeSource get access to the
> visual tree in their ProvideValue implementations?
>
> I want to write a markup extension that walks the tree upward until it finds
> an element with a specified Name but I don't see how I can get to the tree or
> even the element the markup extension is being invoked on (which is inside a
> template).
>
> I've got a scenario where I need to bind to an ancestor just like the
> RelativeSource markup extension allows but I can't do it based on the Type of
> the ancestor, I need to do it based on the Name of the ancestor. This is
> because the item binding is in a template that is hosted in one of several
> different parent templates -- and they each will have an element with the
> proper Name but the types differ.
>
>
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