This is a migrated thread and some comments may be shown as answers.

scrolling a wrapped menu

1 Answer 29 Views
Menu
This is a migrated thread and some comments may be shown as answers.
troy
Top achievements
Rank 1
troy asked on 25 Mar 2010, 02:59 PM

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

1 Answer, 1 is accepted

Sort by
0
Konstantina
Telerik team
answered on 30 Mar 2010, 04:12 PM
Hi troy,

Thank you for contacting us.

You can find information how to put a ScrollViewer around the MenuItems in this blog post.
Hope this helps.

If you have further questions please feel free to contact us again.

Best wishes,
Konstantina
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Menu
Asked by
troy
Top achievements
Rank 1
Answers by
Konstantina
Telerik team
Share this question
or