ContextMenu
을 사용하는 WPF Window 응용 프로그램에서 작업하고 있습니다. 'MenuItem'유형의 스타일을 '구분 기호'유형에 적용 할 수 없습니다.
ContextMenu
(Window.Resources에서) XAML에서 : 나는
ContextMenu
에 구분을 추가하려고하면
<ContextMenu x:Key="menuList" Placement="Bottom" >
<ContextMenu.ItemContainerStyle>
<Style TargetType="{x:Type MenuItem}">
<Setter Property="Header" Value="{Binding Name}"/>
<EventSetter Event="Click" Handler="cm_RefreshChannelNotification"/>
<Setter Property="IsChecked" Value="{Binding CFiltered}" />
<Setter Property="IsCheckable" Value="True"/>
<Setter Property="StaysOpenOnClick" Value="True"/>
</Style>
</ContextMenu.ItemContainerStyle>
</ContextMenu>
내가 오류가 나타납니다 이러한 방법으로
System.InvalidOperationException was unhandled Message="A style intended for type 'MenuItem' cannot be applied to type 'Separator'.
을 나는 새를 추가해야합니다 구분 :
ContextMenu cm = this.FindResource("menuList") as ContextMenu;
Separator separator = new Separator();
separator.SnapsToDevicePixels = true;
cm.Items.Add(separator);
나는 ContextMenu
에 추가/무엇을 변경해야 정의가 작동하도록하려면?
다른 대안이 있습니다. – U62