当用户右键单击我们的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>
Run Code Online (Sandbox Code Playgroud)
但这不起作用:
<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>
Run Code Online (Sandbox Code Playgroud)
有谁知道如何为WPF中的所有TextBox设置样式或禁用默认的ContextMenu?
嗨人stackoverflow.我正在使用MVVM,我让ViewModel使用Property Password调用UserViewModel.在View中有一个控件PasswordBox.
<PasswordBox x:Name="txtPassword" Password="{Binding Password}" />
Run Code Online (Sandbox Code Playgroud)
但是这个xaml不起作用.你怎么做绑定?请帮忙!!