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

Go Back   Vista Forums > Vista technology newsgroups > Avalon

How does a MarkupExtension get to the VisualTree?

Reply
 
Thread Tools Display Modes
Old 01-18-2008   #1
tbrummel
Guest
 
Posts: n/a

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.


  Reply With Quote

Old 04-03-2008   #2
Denis Vuyka
Guest
 
Posts: n/a

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.
>
>
  Reply With Quote
 
Reply

Thread Tools
Display Modes









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