在下面的例子中,当文本获得焦点,但不是按钮菜单中启用。 我曾经使用过的按钮和文本框尝试过,但行为是一样的。
<Window x:Class="WpfPopup.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<DockPanel>
<Menu DockPanel.Dock="Top">
<MenuItem Command="ApplicationCommands.Paste" />
</Menu>
<TextBox BorderBrush="Black" BorderThickness="2" Margin="25" TextWrapping="Wrap" x:Name="text1" Height="58" Width="203" >
The MenuItem will not be enabled until
this TextBox gets keyboard focus
</TextBox>
<Button Content="Button" Height="23" Name="button1" Width="93" Command="ApplicationCommands.Paste" />
</DockPanel>