【发布时间】:2010-09-05 19:05:31
【问题描述】:
显然,当用户在我们的 WPF 应用程序中右键单击并使用 Windows 经典主题时,TextBox 的默认 ContextMenu(包含复制、剪切和粘贴)具有黑色背景。
我知道这很好用:
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<TextBox ContextMenu="{x:Null}"/>
</Page>
但这不起作用:
<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Page.Resources>
<Style x:Key="{x:Type TextBox}" TargetType="{x:Type TextBox}">
<Setter Property="ContextMenu" Value="{x:Null}"/>
</Style>
</Page.Resources>
<TextBox/>
</Page>
有谁知道如何为 WPF 中的所有 TextBox 设置样式或禁用默认 ContextMenu?
【问题讨论】:
-
你不需要考虑禁用快捷键,例如CTRL-V?