Right Align MenuItems in WPF - wpf

Can i right align the menu items in WPF?
Thanks
Sharath

<Menu HorizontalAlignment="Stretch" FlowDirection="RightToLeft">
<MenuItem HorizontalAlignment="Right" Header="aaa">
</MenuItem>
<MenuItem HorizontalAlignment="Right" Header="bbb">
</MenuItem>
</Menu>

Yes, you can.
Although the implementation is a little screwy.
If you want to have the menu items in the top menu go from right to left, add FlowDirection="RightToLeft" to your Menu.
If you want to have an item aligned right in a dropdown, do the following:
<MenuItem>
<MenuItem.Header>
<TextBlock HorizontalAlignment="Right" >Content</TextBlock>
</MenuItem.Header>
</MenuItem>
If you want to do both, you actually have to set HorizontalAlignment="Left" instead of right, as the FlowDirection reverses the right and left in the Alignments. I don't know why, but that's what you have to do.

How do I right-align the 'help' menu item in WPF?
I like the second answer with the grid way.

Related

How to create a menu at the bottom of a metro window in WPF

I want to create a menu at the bottom of a metro window. How should I do it?
Attached image of what I am looking for. Gray area at bottom, over which will have buttons and click of button, popup will be shown with options.
Please suggest.
Set the vertical alignment of menu to bottom
e.g. :
<Menu Height="23" HorizontalAlignment="Stretch" Margin="86,0,0,0" Name="Menu1" VerticalAlignment="Bottom" Width="334">
<MenuItem Header=" My"/>
<MenuItem Header=" My option 2"/>
<MenuItem Header=" My option 3"/>
</Menu>

MenuItem HorizontalAlignment not working

I have a menu inside the grid with on item:
I want to change the horizontal and vertical alignment of this MenuItem to fit the entire grid cell.
I wrote this:
<Menu>
<MenuItem Header="Hello" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
</Menu>
But it stays as before:
I even tried to change the HorizontalAlignment to Center and it's still the same.
How do I accomplish this?
Note: the menu itself is stretched by default - you can see that because of the background color.
update
I need to support subItems. if I only put MenuItem without a Menu opening of sub items is not working.
If you only have single MenuItem and want it to fill the parent panel, you don't need a Menu. This should work:
<Grid Width="200" Height="200">
<MenuItem Header="Hello" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/>
</Grid>
If you have a Menu that may contain several items, it doesn't make much sense for a single item to fill the available space.

How to create vertical menu control in WPF

Iam trying to create vertical menu control but dont know from where to start. I am basically coming from winform to wpf and using telerik controls and this control which am using is called RadMenuControl.
Please view the video in link and suggest me accordingly with code and helping links from where i can start, thanks in advance.
MenuItem Video
You can change the ItemsPanel of Menu control.
Inheritance heirarchy :
ItemsControl > MenuBase > Menu.
<Menu Height="Auto" Width="Auto" FontSize="18">
<Menu.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel/>
</ItemsPanelTemplate>
</Menu.ItemsPanel>
<MenuItem Header="Styling">
<MenuItem Header="Background"/>
</MenuItem>
<MenuItem Header="Measurement">
<MenuItem Header="Width"/>
<MenuItem Header="Height"/>
</MenuItem>
<MenuItem Header="Font"/>
</Menu>
If you need an similar functionality, you may consider using a StackPanel and keep stacking button items to them.
<StackPanel>
<Button Content="Home"/>
<Button Content="Edit"/>
<Button Content="View"/>
</StackPanel>
If you are using Telerik controls would you try RadPanelBar or RadOutlookBar. Surely your requirement will be satisfied one of these two controls.
RadPanelBar

How To Make List Box Transparent? WPF

<telerik:RadExpander Header="View My Team" HorizontalAlignment="Left" Width="274" Margin="34,170,0,450" FontSize="20">
<ListBox x:Name="myTeam" HorizontalAlignment="Left" Height="214" VerticalAlignment="Top" Width="264" Margin="0,0,-103,-1" Background="Transparent" Foreground="{x:Null}" BorderBrush="{x:Null}">
<MenuItem Header="Ben Clarke" Background="Transparent"/>
<MenuItem Header="Jack Davies" Background="Transparent"/>
<MenuItem Header="Harry Potter" Background="Transparent"/>
<MenuItem Header="Bill Gates" Background="Transparent"/>
</ListBox>
</telerik:RadExpander>
I have this code where my list box is inside the expander which is all working fine, but i cannot get the list box to be transparent background so that it just shows the names and then the roll-over effect etc ... The background is just appearing white.
As you can see i have added the background Transparent to all the MenuItems and the Listbox itself and it still hasn't worked :(
Maybe some usage of the Opacity property can do it? Either on the ListBox or on the MenuItems (don't know if they got Opacity property)?

WPF Menu keyboard navigation problems

I've got a WPF program containing a simple Menu.
When The keyboard focus is set into the menu, in Win32 I was able to jump to menu items by typing the first character of the MenuItem name.
In WPF menus this does not work anymore, unless I mark the first character of the menu item using an underscore.
Is this a bug or a feature?
This is supported in wpf also.It is done by adding an underscore in front of a character.
(The ampersand does not work in WPF!).Check the below sample
<Menu Height="22" Name="menu1" Width="200" Margin="10, 10, 5, 5" HorizontalAlignment="Left" VerticalAlignment="Top" BorderThickness="2">
<MenuItem Header="_File">
<MenuItem Header="_Open" IsCheckable="False">
<MenuItem Header="_One" IsCheckable="True"/>
<MenuItem Header="_Two" IsCheckable="True"/>
</MenuItem>
<MenuItem Header="_Close" IsCheckable="True"/>
<MenuItem Header="_Save" IsCheckable="True"/>
</MenuItem>
</Menu>
The underlined characters show up when you press the Alt key to access the menu. You can then navigate the menu by pressing the underlined characters

Resources