Is there anyway to setup the width of the submenu dropdown to be set automatically to the width of the screen?
Right now, it appears that the width gets set based on the number of items.
TIA.
Hi
There is not property in the menu which sets the width of the submenu dropdown. But you can do this using ControlTemplate of the menu and little code behind.
First you have extract the MenuItem ControlTemplate using Blend.
I have attached a sample with extracted ControlTemplate.
Second Write converter that returns the plugin’s width
public class WidthToScreen : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
return Application.Current.Host.Content.ActualWidth;
}
Third Bind the popup child width to menu item with using converter.
<Border x:Name="PopupBorder" Width="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Width, Converter={StaticResource MyConverter}}" />
This is the points how to resolve your issue.
I have attached files that do this functionality.
That did the trick! Thanks a lot!