Open wieslawsoltes opened 6 years ago
@wieslawsoltes it's a feature added in https://github.com/AvaloniaUI/Avalonia/pull/1891 :smile:
So how can I force not to make menu item a separator?
Why do you need a menu item with a header of "-"?
I use it for remove button like this:
<Menu Grid.Row="2" HorizontalAlignment="Right" IsVisible="{Binding !!$self.DataContext}">
<MenuItem Header="apply" Command="{Binding $parent[Window].DataContext.OnApplyStyle}" CommandParameter="{Binding Selected}" IsVisible="{Binding !!Selected}"/>
<MenuItem Header="+" Command="{Binding $parent[Window].DataContext.OnAddStyle}" CommandParameter="{Binding}"/>
<MenuItem Header="-" Command="{Binding $parent[Window].DataContext.OnRemoveStyle}" CommandParameter="{Binding Selected}" IsVisible="{Binding !!Selected}"/>
</Menu>
I should have known that someone would be using a menu item with just a "-". Sigh. I wonder how you do this in winforms?
maybe we can use something less likely for separators, like empty string or ":separator" or something.
No, someone will want to use whatever string as a menu item. I actually think "-" is the best string to use as it's use as a separator is widespread, we're just following patterns used in other frameworks. Would suggesting that an em-dash or another char be used instead in the unusual case of wanting a dash as a menu be acceptable do you think?
I will use Header="X"
for my menu items as its seems like -
for separator is convenient to use.
Anyway it would be good to have some mechanism to disable this behavior.
You could use <MenuItem Header="˗"/>
Anyway it would be good to have some mechanism to disable this behavior.
Yes, I am looking to see how you do this in WinForms.
Needs a new MenuSeparator
similar to UWP:
@robloo we have a Separator. It basically works exactly like MenuSeparator in UWP. There are styles for "MenuItem > Separator" selector to make it look right.
"-" support was specifically added before to simplify some use cases https://github.com/AvaloniaUI/Avalonia/pull/1891. But broke another rare scenario.
Setting MenuItem Header to - makes it separator and does not display text.
repro:
style used:
version: 0.6.2-build6248-beta