TextBox ContextMenu usage improvement #2772

Merged
merged 4 commits into from Dec 20, 2016

Conversation

Projects
None yet
3 participants
@punker76
Member

punker76 commented Dec 20, 2016

What changed?

@Deadpikle created this PR Added more TextBox ContextMenu configuration #2758 which was a good idea to enhance the current ContextMenu implementation. I need some days to review theses changes and come to the conclusion that we don't need this extra attached properties to add some more context menu items to the default one and the spell checker items.

So here is my solution...

  • If you want to use the default context menu items cut, copy and paste you must do nothing
  • If you want to use your own context menu items without the default items you must do this
<TextBox Text="Yeahh">
    <TextBox.ContextMenu>
        <ContextMenu>
            <MenuItem Header="This is only a Test-Item" />
        </ContextMenu>
    </TextBox.ContextMenu>
</TextBox>
  • If you want to use your own context menu items with the spell checker items then you must do this
<TextBox Margin="{StaticResource ControlMargin}"
         Controls:TextBoxHelper.IsSpellCheckContextMenuEnabled="True"
         Text="Enabled">
    <TextBox.ContextMenu>
        <ContextMenu>
            <MenuItem Header="This is only a Test-Item" />
        </ContextMenu>
    </TextBox.ContextMenu>
</TextBox>
  • If you want to use your own context menu items with the deafult items then you must do this
<TextBox Controls:TextBoxHelper.ClearTextButton="True"
         Controls:TextBoxHelper.UseFloatingWatermark="True"
         Controls:TextBoxHelper.Watermark="Watermark">
    <TextBox.ContextMenu>
        <ContextMenu>
            <MenuItem Header="Custom Item" />
            <Separator />
            <MenuItem Style="{DynamicResource MetroMenuItem}" Command="ApplicationCommands.Cut" />
            <MenuItem Style="{DynamicResource MetroMenuItem}" Command="ApplicationCommands.Copy" />
            <MenuItem Style="{DynamicResource MetroMenuItem}" Command="ApplicationCommands.Paste" />
        </ContextMenu>
    </TextBox.ContextMenu>
</TextBox>
@thoemmi

This comment has been minimized.

Show comment
Hide comment
@thoemmi

thoemmi Dec 20, 2016

Collaborator

I like that. I was unsure about the changes proposed by @Deadpikle, because it solved a very special use case. @punker76 your solution is much more general, which I prefer.

Collaborator

thoemmi commented Dec 20, 2016

I like that. I was unsure about the changes proposed by @Deadpikle, because it solved a very special use case. @punker76 your solution is much more general, which I prefer.

@punker76 punker76 merged commit 8e2f6db into develop Dec 20, 2016

1 check passed

continuous-integration/teamcity Finished TeamCity Build MahApps.Metro PullRequest :: MahApps.Metro PullRequests : Tests passed: 62
Details
@Deadpikle

This comment has been minimized.

Show comment
Hide comment
@Deadpikle

Deadpikle Dec 20, 2016

Contributor

@punker76 Yeah, that's a much better solution. Thanks!

Contributor

Deadpikle commented Dec 20, 2016

@punker76 Yeah, that's a much better solution. Thanks!

@punker76 punker76 deleted the ContextMenu-Test branch Dec 21, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment