使用此XAML:
<DockPanel>
<Menu DockPanel.Dock="Top">
<MenuItem Header="_Edit">
<MenuItem Command="ApplicationCommands.Cut"/>
<MenuItem Command="ApplicationCommands.Paste"/>
</MenuItem>
</Menu>
<WrapPanel DockPanel.Dock="Top" Margin="3">
<Button Command="ApplicationCommands.Cut" Width="60">_Cut</Button>
<Button Command="ApplicationCommands.Paste" Width="60" Margin="3,0">_Paste</Button>
</WrapPanel>
<TextBox TextWrapping="Wrap" AcceptsReturn="True"
VerticalScrollBarVisibility="Visible"/>
</DockPanel>
我可以从MenuItems调用内置剪切和粘贴命令,但不能从按钮调用!?怎么了?
答案 0 :(得分:1)
这些只有在MenuItem
或ToolBar
内才有效。
<ToolBar>
<Button Command="ApplicationCommands.Cut" Width="60">_Cut</Button>
<Button Command="ApplicationCommands.Paste" Width="60" Margin="3,0">_Paste</Button>
</ToolBar>