HeaderContextMenu For RadGridView have Issue in Opening of SubMenu Items

3 posts, 0 answers
  1. Anand
    Anand avatar
    12 posts
    Member since:
    Apr 2014

    Posted 14 Oct 2014 Link to this post

    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. Anand
    Anand avatar
    12 posts
    Member since:
    Apr 2014

    Posted 14 Oct 2014 in reply to Anand Link to this post

    Line: 56
    Error: Unhandled Error in Silverlight Application 
    Code: 2531    
    Category: ParserError       
    Message: Failed to assign to property 'System.Windows.Controls.ContentPresenter.Content'.     
    Line: 5545     
    Position: 33     

    This error is coming 
  3. Boris
    Boris avatar
    276 posts

    Posted 15 Oct 2014 Link to this post

    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 };
            subMenu.Header = columnHeader.Text;
            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);

    I hope this helps.

    Boris Penev

    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.

Back to Top