WPF:在Expression Blend 4中编辑上下文菜单或工具提示:错误“;不能有逻辑或可视父级。”;
我想根据Expression Blend 4中的默认设置为ContextMenu或工具提示创建新样式。为此,我执行以下操作(例如ContextMenu):WPF:在Expression Blend 4中编辑上下文菜单或工具提示:错误“;不能有逻辑或可视父级。”;,wpf,contextmenu,tooltip,blend,Wpf,Contextmenu,Tooltip,Blend,我想根据Expression Blend 4中的默认设置为ContextMenu或工具提示创建新样式。为此,我执行以下操作(例如ContextMenu): 在eblend4中创建新的WPF应用程序 把按钮放在窗户上 为按钮创建新的上下文菜单 将两个示例项添加到ContextMenu(标题为“item1”和“item2”) 在按钮中的“属性”面板上下文菜单属性属性在“样式”属性下单击“样式”属性右侧的方框,然后选择“转换为新资源…” 在打开的“创建样式资源”窗口中,为“此文档[window:win
<Style x:Key="ContextMenuStyle1" TargetType="{x:Type ContextMenu}">
<Setter Property="Background" Value="{DynamicResource MenuBackgroundBrush}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="BorderBrush" Value="{DynamicResource WindowBorderBrush}"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ContextMenu}">
<Border Uid="Border_93">
<Border.Style>
<Style TargetType="{x:Type Border}">
<Setter Property="Tag" Value="{DynamicResource {x:Static SystemParameters.DropShadowKey}}"/>
<Style.Triggers>
<DataTrigger Binding="{Binding Tag, RelativeSource={RelativeSource Self}}" Value="True">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Padding" Value="0,0,5,5"/>
<Setter Property="Effect">
<Setter.Value>
<DropShadowEffect BlurRadius="4" Opacity="0.8" ShadowDepth="1"/>
</Setter.Value>
</Setter>
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Uid="Border_50">
<ScrollViewer CanContentScroll="True" Style="{DynamicResource {ComponentResourceKey ResourceId=MenuScrollViewer, TypeInTargetAssembly={x:Type FrameworkElement}}}" Uid="ScrollViewer_9">
<ItemsPresenter KeyboardNavigation.DirectionalNavigation="Cycle" Margin="{TemplateBinding Padding}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Uid="ItemsPresenter_5"/>
</ScrollViewer>
</Border>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
这是Microsoft Expression Blend中的一个
bug
,请查看以下链接: