0

With this 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>

I can invoke built-in Cut and Paste Commands from MenuItems, but not from Buttons? What's wrong?

2
  • 1
    Are you seeing binding errors? Commented Jan 5, 2017 at 16:04
  • 1
    Shouldn't it be Command="{Binding ApplicationCommands.Cut}", should it? Commented Jan 5, 2017 at 16:06

1 Answer 1

0

These only work if they are inside a MenuItem or ToolBar.

<ToolBar>
    <Button Command="ApplicationCommands.Cut" Width="60">_Cut</Button>
    <Button Command="ApplicationCommands.Paste" Width="60" Margin="3,0">_Paste</Button>
</ToolBar>
Sign up to request clarification or add additional context in comments.

1 Comment

OK, that way works. But is there an explanation?! Why Button must be inside MenuItem or ToolBar?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.