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

menu item dropdownheight dynamic

1 Answer 97 Views
ContextMenu
This is a migrated thread and some comments may be shown as answers.
Piyush
Top achievements
Rank 1
Piyush asked on 01 Apr 2015, 10:22 AM
i want to have a scroll to be added in the submenu item list.
if im making radmenuItem.DropDownHeight = 200, then i can achieve wat want. 
but issue arise when the submenu item are less(say2), then submenuitem list shows 2 submenu item and rest space is show blank, ie. it takes minumun height to the submenu item list as 200.

FUNCTION: 
  private void AddtoReporMenuItem_OnMouseEnter(object sender, MouseEventArgs e)
        {
            var treeViewModel = this.DataContext as TreeViewModel;
            if(radcontextMenu.Items.Count>2)
                radcontextMenu.Items.RemoveAt(2);
            RadMenuItem  reportItem = new RadMenuItem(){Header = "Add to Report"};
            RadMenuItem reportNamesItem;
            RadMenuGroupItem reportsList = new RadMenuGroupItem();
            if (treeViewModel.Reports != null)
            {
                foreach (var report in treeViewModel.Reports)
                {
                    reportNamesItem = new RadMenuItem();
                    reportNamesItem.Header = report.ReportName;
                    reportNamesItem.Click += (senderObj, eventargs) => reportItem_Click(senderObj, eventargs, report);
                    reportsList.Items.Add(reportNamesItem);
                }
               
                reportItem.Items.Add(reportsList);
                reportItem.DropDownHeight = 200;
                radcontextMenu.Items.Add(reportItem);
            }

        }




xaml:
   <telerik:RadContextMenu.ContextMenu>
                <telerik:RadContextMenu x:Name="radcontextMenu" MouseEnter="AddtoReporMenuItem_OnMouseEnter">
                    <telerik:RadMenuItem Header="{localization:Translate DeleteTxt}" Command="{Binding Path=DeleteChartDash}" />
                    <telerik:RadMenuItem Header="{localization:Translate ExportButton}">
                        <telerik:RadMenuItem Header="CSV" Command="{Binding Path=ExportCommand}" CommandParameter="ExportChart" />
                        <telerik:RadMenuItem Header="{localization:Translate ExportdataTxt}" Command="{Binding Path=ExportCommand}" CommandParameter="ExportData"  />
                        <telerik:RadMenuItem Header="{localization:Translate PowerPointTxt}" Command="{Binding Path=ExportCommand}" CommandParameter="ExportPPT"  />
                        </telerik:RadMenuItem>
                </telerik:RadContextMenu>
            </telerik:RadContextMenu.ContextMenu>




1 Answer, 1 is accepted

Sort by
0
Kalin
Telerik team
answered on 02 Apr 2015, 11:50 AM
Hello Piyush,

Please check my reply in the following thread, it should help you to achieve the desired:
http://www.telerik.com/forums/maximum-dropdownheight

Hope this helps.

Regards,
Kalin
Telerik
 

See What's Next in App Development. Register for TelerikNEXT.

 
Tags
ContextMenu
Asked by
Piyush
Top achievements
Rank 1
Answers by
Kalin
Telerik team
Share this question
or