【wpf】用Button和TextBox实现路由命令的问题
代码如下:
<StackPanel>
<Menu Width="Auto" Height="20" DockPanel.Dock="Top">
<MenuItem Command="ApplicationCommands.Copy" Header="{Binding Path=Command.Text, RelativeSource={RelativeSource Self}}"/>
</Menu>
<TextBox x:Name="textBoxA"/>
<Button x:Name="buttonA" Command="ApplicationCommands.Copy" Content="{Binding Path=Command.Text,RelativeSource={RelativeSource Self}}"/>
<Button x:Name="buttonB" Command="Paste" Content="{Binding Path=Command.Text,RelativeSource={RelativeSource Self}}"/>
<Button x:Name="buttonC" Command="Redo" Content="{Binding Path=Command.Text,RelativeSource={RelativeSource Self}}"/>
<Button x:Name="buttonD" Command="Undo" Content="{Binding Path=Command.Text,RelativeSource={RelativeSource Self}}"/>
</StackPanel>
提问:为什么使用wpf自带命令,MenuItem正常而 Button始终灰化不可使用?
------解决方案--------------------已了解原理,自己结了吧。