Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TextBox ContextMenu usage improvement #2772

Merged
merged 4 commits into from
Dec 20, 2016
Merged

TextBox ContextMenu usage improvement #2772

merged 4 commits into from
Dec 20, 2016

Conversation

punker76
Copy link
Member

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
Copy link
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
@Deadpikle
Copy link
Contributor

Deadpikle commented Dec 20, 2016

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

@punker76 punker76 deleted the ContextMenu-Test branch December 21, 2016 19:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants