0
我宣佈我的控制style
庫:如何覆蓋全局風格的ContextMenu?
<ContentControl.Resources>
<ContextMenu x:Key="ContextMenu">
<MenuItem Header="{x:Static Drawing:Headers.AddEdge}" Click="AddEdgeClick"/>
<MenuItem Header="{x:Static Drawing:Headers.ChangeID}" Click="ChangeIDClick"/>
<MenuItem Header="{x:Static Drawing:Headers.Remove}" Click="RemoveClick"/>
</ContextMenu>
<Style x:Key="Style" TargetType="{x:Type Drawing:Node}">
<Setter Property="ContextMenu" Value="{StaticResource ContextMenu}"/>
</Style>
</ContentControl.Resources>
<ContentControl.Style>
<StaticResource ResourceKey="Style"/>
</ContentControl.Style>
但對於這種控制在應用程序不工作全局樣式...
<Style TargetType="Drawing:Node">
<Setter Property="ContextMenu" Value="{x:Null}"/>
<EventSetter Event="MouseLeftButtonUp" Handler="DirectoryClicked"/>
</Style>
哦,對不起。我在控制庫中使用第一個樣本,但第二個樣本在應用程序中使用。 – 2011-03-14 04:16:57