How do I right-align the 'help' menu item
In WPF I can use the below to right-align the 'help' menu
Could I do it in Noesis GUI?
Code: Select all
<Menu Height="20" Background="#FFA9D1F4">
<Menu.ItemsPanel>
<ItemsPanelTemplate>
<DockPanel HorizontalAlignment="Stretch"/>
</ItemsPanelTemplate>
</Menu.ItemsPanel>
<MenuItem Header="File">
<MenuItem Header="Exit"/>
</MenuItem>
<MenuItem Header="Edit">
<MenuItem Header="Cut"/>
</MenuItem>
<MenuItem Header="Help" HorizontalAlignment="Right">
<MenuItem Header="About"/>
</MenuItem>
</Menu>
Code: Select all
+-------------------------------------------+
| File Edit Help |
+-------------------------------------------+
| |
Re: How do I right-align the 'help' menu item
Could you try to explicitly set the width of the menu to some large number, and observe the effect?
Peter Verswyvelen,
Strongly Typed Solutions
Strongly Typed Solutions
Re: How do I right-align the 'help' menu item
Instead of HorizontalAlignment="Right" for the help menu can you try DockPanel.Dock="Right"? That might work. https://wpftutorial.net/DockPanel.html
Re: How do I right-align the 'help' menu item
I tried playing with this code in Kaxaml and the Noesis XamlPlayer, and as far as I can tell, this is a bug, Menu seems to ignore the ItemsPanel completely.
For example, the following code
still layouts each MenuItem horizontally stacked
For example, the following code
Code: Select all
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<Menu Foreground="White">
<Menu.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel IsItemsHost="True" Orientation="Vertical" Background="Skyblue"/>
</ItemsPanelTemplate>
</Menu.ItemsPanel>
<MenuItem Header="File">
<MenuItem Header="Exit"/>
</MenuItem>
<MenuItem Header="Edit">
<MenuItem Header="Cut"/>
</MenuItem>
<MenuItem Header="Help">
<MenuItem Header="About"/>
</MenuItem>
</Menu>
</UserControl>
Peter Verswyvelen,
Strongly Typed Solutions
Strongly Typed Solutions
Re: How do I right-align the 'help' menu item
If I include the Noesis style into the XAML, the WPF version also fails. So it seems the default Noesis Menu template is wrong. Investigating further.
Peter Verswyvelen,
Strongly Typed Solutions
Strongly Typed Solutions
Re: How do I right-align the 'help' menu item
Indeed, the builtin Noesis style for Menu is wrong (well actually, so is the MSDN documentation).
I assume you're using `NoesisStyle.xaml` as your theme.
Open `NoesisStyle.xaml`, and search for `<Style TargetType="{x:Type Menu}"`.
Then replace the following code
by
I assume you're using `NoesisStyle.xaml` as your theme.
Open `NoesisStyle.xaml`, and search for `<Style TargetType="{x:Type Menu}"`.
Then replace the following code
Code: Select all
<StackPanel IsItemsHost="True" Orientation="Horizontal"/>
Code: Select all
<ItemsPresenter/>
Peter Verswyvelen,
Strongly Typed Solutions
Strongly Typed Solutions
Re: How do I right-align the 'help' menu item
Good find! I recommend report it on the bug tracker.
Re: How do I right-align the 'help' menu item
Working on it! I'll provide a patch too.
Peter Verswyvelen,
Strongly Typed Solutions
Strongly Typed Solutions
-
-
sfernandez
Site Admin
- Posts: 3197
- Joined:
Re: How do I right-align the 'help' menu item
Thanks for all the investigation here Ziriax.
We will include the patch in the following release.
PhiLong, meanwhile you can override default template in the Menu to apply the patch locally:
We will include the patch in the following release.
PhiLong, meanwhile you can override default template in the Menu to apply the patch locally:
Code: Select all
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<Menu Foreground="White">
<Menu.Template>
<ControlTemplate TargetType="Menu">
...
</ControlTemplate>
</Menu.Template>
<Menu.ItemsPanel>
<ItemsPanelTemplate>
<DockPanel IsItemsHost="True" LastChildFill="False"/>
</ItemsPanelTemplate>
</Menu.ItemsPanel>
<MenuItem Header="File" DockPanel.Dock="Left">
<MenuItem Header="Exit"/>
</MenuItem>
<MenuItem Header="Edit" DockPanel.Dock="Left">
<MenuItem Header="Cut"/>
</MenuItem>
<MenuItem Header="Help" DockPanel.Dock="Right">
<MenuItem Header="About"/>
</MenuItem>
</Menu>
</UserControl>
-
-
sfernandez
Site Admin
- Posts: 3197
- Joined:
Re: How do I right-align the 'help' menu item
Default styles fixed in NoesisGUI 2.0.1 to use ItemsPresenter in all the items controls.
Who is online
Users browsing this forum: Bing [Bot], Semrush [Bot] and 1 guest