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

HeaderContextMenu For RadGridView have Issue in Opening of SubMenu Items

2 Answers 24 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Anand
Top achievements
Rank 1
Anand asked on 14 Oct 2014, 05:01 PM
Hello All,

I have a requirement for HeaderContextMenu So I followed the link http://demos.telerik.com/silverlight/#GridView/HeaderContextMenu . I used the same class GridViewHeaderMenu for achieving this. 

Problem is when ever I try to open submenu. OnMouse hover of it My Application break. I'm not getting why this issue is occurring & how to resolve this.

2 Answers, 1 is accepted

Sort by
0
Anand
Top achievements
Rank 1
answered on 14 Oct 2014, 05:09 PM
Line: 56
Error: Unhandled Error in Silverlight Application 
Code: 2531    
Category: ParserError       
Message: Failed to assign to property 'System.Windows.Controls.ContentPresenter.Content'.     
File:      
Line: 5545     
Position: 33     



This error is coming 
0
Boris
Telerik team
answered on 15 Oct 2014, 02:42 PM
Hi Anand,

The described issue occurs because you have a custom header defined for some of your columns. There are two possible workarounds:
1) Set the Header property of these column to a string, instead of a custom header.
2) For example if you have a TextBlock defined in a StackPanel as a custom header, you can modify the OnMenuOpened() method from the GridViewHeaderMenu.cs file in the following way:

foreach (GridViewColumn column in grid.Columns)
{
    RadMenuItem subMenu = new RadMenuItem();
  
    if (column.Header is StackPanel)
    {
        var columnHeader = (column.Header as StackPanel).ChildrenOfType<TextBlock>().FirstOrDefault();
        StackPanel sp = new StackPanel();
        var tb = new TextBlock() { Text = columnHeader.Text };
  
        sp.Children.Add(tb);
        subMenu.Header = columnHeader.Text;
    }
    else
    {
        subMenu.Header = column.Header;
    }
    subMenu.IsCheckable = true;
    subMenu.IsChecked = true;
  
    Binding isCheckedBinding = new Binding("IsVisible");
    isCheckedBinding.Mode = BindingMode.TwoWay;
    isCheckedBinding.Source = column;
  
    // bind IsChecked menu item property to IsVisible column property
    subMenu.SetBinding(RadMenuItem.IsCheckedProperty, isCheckedBinding);
  
    item.Items.Add(subMenu);
}

I hope this helps.


Regards,
Boris Penev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
GridView
Asked by
Anand
Top achievements
Rank 1
Answers by
Anand
Top achievements
Rank 1
Boris
Telerik team
Share this question
or