0

I use Xceeed Wpf Toolkit and IntegerUpDown:

 xmlns:XceedToolkit="clr-namespace:Xceed.Wpf.Toolkit;assembly=Xceed.Wpf.Toolkit"

 <XceedToolkit:IntegerUpDown Grid.Column="1" Value="{Binding SelectedYear}" HorizontalAlignment="Stretch" VerticalAlignment="Center"/>

But, when i do right click on this control, take this:

xceed IntegerUpdown controlContextMenu

If i make right click on anohter control like TextBox it is look normal. Can you help me to fix it?

Admiral Land
  • 2,304
  • 7
  • 43
  • 81

1 Answers1

1

According to WPF Textbox's TextAlignment changes its default context menu item's alignment as well, you have to rebuild the context menu, since the default can't be changed.

<XceedToolkit:IntegerUpDown>
    <XceedToolkit:IntegerUpDown.ContextMenu>
            <ContextMenu TextBlock.TextAlignment="Left">
                <MenuItem Command="ApplicationCommands.Copy" />
                <MenuItem Command="ApplicationCommands.Cut" />
                <MenuItem Command="ApplicationCommands.Paste" />
            </ContextMenu>
    </XceedToolkit:IntegerUpDown.ContextMenu>
</XceedToolkit:IntegerUpDown>

The issue is not specific to XceedToolkit:IntegerUpDown but applies to many controls with default context menu and TextAlignment property.

If you rather want to hack around with styles instead of replacing the context menu, your best bet for a target might be the Popup, since the context menu elements are internal classes somewhere, so creating a style for them won't work out of the box.

<XceedToolkit:IntegerUpDown>
    <xt:IntegerUpDown.Resources>
        <Style TargetType="Popup">
            <Setter Property="TextBlock.TextAlignment" Value="Left"/>
        </Style>
    </xt:IntegerUpDown.Resources>
</xt:IntegerUpDown>
grek40
  • 13,113
  • 1
  • 24
  • 50