Setting a WPF ContextMenu's PlacementTarget property in XAML?
Posted
by qntmfred
on Stack Overflow
See other posts from Stack Overflow
or by qntmfred
Published on 2009-08-13T14:18:10Z
Indexed on
2010/06/18
16:23 UTC
Read the original article
Hit count: 1444
<Button Name="btnFoo" Content="Foo" >
<Button.ContextMenu Placement="Bottom" PlacementTarget="btnFoo">
<MenuItem Header="Bar" />
</Button.ContextMenu>
</Button>
gives me a runtime error 'UIElement' type does not have a public TypeConverter class
I also tried
<Button Name="btnFoo" Content="Foo" >
<Button.ContextMenu Placement="Bottom" PlacementTarget="{Binding ElementName=btnFoo}">
<MenuItem Header="Bar" />
</Button.ContextMenu>
</Button>
and that put the ContextMenu in the top left corner of my screen, rather than at the Button
© Stack Overflow or respective owner