Search code examples
wpfxamlthemesmenuitemvirtualizingstackpanel

VirtualizingStackPanel not aligning menu items vertical on applying theme


Before applying WPF theme - BureauBlue.xaml theme, I can see menu items aligning vertically with the below code:

<Menu.ItemsPanel>
    <ItemsPanelTemplate>
        <VirtualizingStackPanel Orientation="Vertical"/>
    </ItemsPanelTemplate>
</Menu.ItemsPanel>

But the same logic is aligning the menu items horizontally once I apply the theme.

Could you please assist me in resolving this?


Solution

  • I am able to solve the problem.

    I am supposed to use VirtualizingStackPanel to display the menu items vertically.

    In the theme style for Menu, StackPanel orientation is coded as Horizontal.

    I just copied the code from the theme xaml and created a new style where the only change is Orientation from Horizontal to Vertical.

    For the Menu, I have applied the new style as a DynamicResource.

    It worked.

    Thanks...