I am modeling an attached command pattern after the <a href="http://marlongrech.wordpress.com/2008/12/13/attachedcommandbehavior-v2-aka-acb/" rel="nofollow">AttachedCommandBehavior library here</a>. My button looks like this:
Everything works great, but when the setter on the
is executed, the Command is
.
Behavior is a
, and Behaviors is a
. It just doesn't seem to be inheriting the DataContext from the Button.
On the other hand, this works correctly:
Unfortunately I can't do it this way, because I need to target generated
s using
.
Is there some way to get the DataContext in the Style?
Code:
<Button>
<Button.Style>
<Style TargetType="{x:Type Button}">
<Setter Property="vms:Attached.Behaviors">
<Setter.Value>
<vms:Behaviors>
<vms:Behavior Event="Click"
Command="{Binding ClickCommand}" />
</vms:Behaviors>
</Setter.Value>
</Setter>
</Style>
</Button.Style>
</Button>
Everything works great, but when the setter on the
Code:
Behavior
Code:
null
Behavior is a
Code:
Freezable
Code:
FreezableCollection<Behavior>
On the other hand, this works correctly:
Code:
<Button>
<vms:Attached.Behaviors>
<vms:Behavior Event="Click" Command="{Binding ClickCommand}" />
</vms:Attached.Behaviors>
</Button>
Unfortunately I can't do it this way, because I need to target generated
Code:
ListViewItem
Code:
ItemContainerStyle
Is there some way to get the DataContext in the Style?