I have a menu that contains many nested submenus. As there are sometimes too many to display on the page, I created a style to implement the RadWrapPanel which correctly wraps the menus. The problem is that if there are still too many it rolls off the screen. I have tried to implement a ScrollViewer but with no success. I have created a test for you to view.
Here is the XAML:
<UserControl.Resources>
<Style x:Name="wrapStyle" x:Key="ItemStyle" TargetType="telerikNavigation:RadMenuItem">
<Style.Setters>
<SetterProperty="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<!--set different MaxHeight to control the size of the menu-->
<tk:RadWrapPanel Orientation="Vertical" MaxHeight="600"/>
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<SetterProperty="Template">
<Setter.Value>
<ControlTemplate>
<ScrollViewer HorizontalScrollBarVisibility="Visible">
<ItemsPresenter/>
</ScrollViewer>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style.Setters>
</Style>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="White">
<Border Grid.Row="1" Margin="20">
<StackPanel>
<telerikNavigation:RadMenuName="menuFeat" Visibility="Visible" ClickToOpen="True">
<telerikNavigation:RadMenuItem Name="menuItemRoot" Style="{StaticResourceItemStyle}" Header="AddFeature(s)" StaysOpenOnClick="True"/>
</telerikNavigation:RadMenu>
</StackPanel>
</Border>
</Grid>
And here is the code behind which populates the menu:
for(int i=0;i<1000;i++)
{
RadMenuItem mi=new RadMenuItem();
mi.Style=wrapStyle;
mi.Header=string.Format("SubMenu {0}",i);
menuItemRoot.Items.Add(mi);
for(int j=0;j<10;j++)
{
RadMenuItem mileaf=new RadMenuItem();
mileaf.Header=string.Format("LeafMenu {0}",j);
mileaf.StaysOpenOnClick=true;
mileaf.IsCheckable=true;
mileaf.Style=wrapStyle;
mi.Items.Add(mileaf);
}
}
Any help would be greatly appreciated!
Troy