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.
>
>
| |
| | |