DataContext as Source for Converter Binding Within Resources
Posted
by loafofbread
on Stack Overflow
See other posts from Stack Overflow
or by loafofbread
Published on 2010-06-07T14:39:02Z
Indexed on
2010/06/07
14:42 UTC
Read the original article
Hit count: 306
<Style TargetType="{x:Type local:SomeControl}">
<Canvas.DataContext>
<ViewModels:VMSomeControl Model="{Binding RelativeSource={RelativeSource TemplatedParent}}" />
</Canvas.DataContext>
<Canvas.Resources>
<!-- is there a way to use a binding that points to the datacontext within the resources ? -->
<Converters:SomeConverter x:Key="someConverter"
SomeProperty="{Binding Path=Model.SomeProperty}" />
<!-- is there a way to point Directly to the TemplatedParent ? -->
<Converters:SomeConverter x:Key="someConverter"
SomeProperty="{TemplateBinding Path=SomeProperty}" />
</Canvas.Resources>
<SomeFrameworkElement SomeProperty="{Binding Path=Model.SomeOtherProperty, Converter={StaticResource someConverter}}" />
</Canvas>
is it possible to use bindings that use either the dataContext or the TemplatedParent Within a ControlTemplate's Root Visuals resourecs ?
© Stack Overflow or respective owner