Created
July 13, 2012 08:33
-
-
Save pinzolo/3103668 to your computer and use it in GitHub Desktop.
[WPF]コンテキストメニューのバインディングにてセパレータを動的に生成する
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ContextMenu ItemsSource="{Binding Menus}"> | |
<ContextMenu.ItemContainerStyle> | |
<Style TargetType="{x:Type MenuItem}"> | |
<Setter Property="Header" Value="{Binding Title}" /> | |
<Setter Property="Command" Value="{Binding Command}" /> | |
<Setter Property="IsEnabled" Value="{Binding IsEnabled}" /> | |
<Style.Triggers> | |
<DataTrigger Binding="{Binding IsSeparator}" Value="True"> | |
<Setter Property="Template"> | |
<Setter.Value> | |
<ControlTemplate> | |
<Separator Style="{StaticResource {x:Static MenuItem.SeparatorStyleKey}}" /> | |
</ControlTemplate> | |
</Setter.Value> | |
</Setter> | |
</DataTrigger> | |
</Style.Triggers> | |
</Style> | |
</ContextMenu.ItemContainerStyle> | |
</ContextMenu> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment