scrolling a wrapped menu

2 posts, 0 answers
  1. troy
    troy avatar
    20 posts
    Member since:
    Jun 2008

    Posted 25 Mar 2010 Link to this post

    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

  2. Konstantina
    Admin
    Konstantina avatar
    2332 posts

    Posted 30 Mar 2010 Link to this post

    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.
  3. DevCraft banner
Back to Top