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

Error changing column visibility with RadContextMenu

0 Answers 38 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Vic
Top achievements
Rank 1
Vic asked on 28 May 2012, 11:17 PM
I am trying to build a simple context menu for changing column visibility that is virtually identical to the sample file included in this post http://www.telerik.com/community/forums/wpf/gridview/changing-column-visibility-in-a-context-menu.aspx. But I'm encountering the following error: 

An unhandled exception of type 'System.InvalidOperationException' occurred in PresentationFramework.dll

Additional information: Specified element is already the logical child of another element. Disconnect it first.

Here's a snippet of my markup:

<telerik:RadGridView Name="MyGridView" ItemsSource="{Binding Source={x:Static local:MainWindow.MyData}}" AutoGenerateColumns="False">
<telerik:RadGridView.Columns> 
<telerik:GridViewDataColumn DataMemberBinding="{Binding Item}" UniqueName="Item" TextAlignment="Center">
<telerik:GridViewDataColumn.Header>
<TextBlock Text="Item Name" HorizontalAlignment="Center"></TextBlock>
</telerik:GridViewDataColumn.Header>
</telerik:GridViewDataColumn>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Category}" UniqueName="Category" TextAlignment="Center">
<telerik:GridViewDataColumn.Header>
<TextBlock Text="Item Category" HorizontalAlignment="Center"></TextBlock>
</telerik:GridViewDataColumn.Header>
</telerik:GridViewDataColumn>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Desc}" UniqueName="Desc" TextAlignment="Center">
<telerik:GridViewDataColumn.Header>
<TextBlock Text="Description" HorizontalAlignment="Center"></TextBlock>
</telerik:GridViewDataColumn.Header>
</telerik:GridViewDataColumn> 
</telerik:RadGridView.Columns>
<telerik:RadContextMenu.ContextMenu>
<telerik:RadContextMenu Opened="RadContextMenu_Opened">
<telerik:RadContextMenu.ItemTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding IsVisible}" Content="{Binding Header}" />
</DataTemplate>
</telerik:RadContextMenu.ItemTemplate>
</telerik:RadContextMenu>
</telerik:RadContextMenu.ContextMenu>
</telerik:RadGridView>

I am evaluating trial version 2012_1_326.
Your help is appreciated.

No answers yet. Maybe you can help?

Tags
GridView
Asked by
Vic
Top achievements
Rank 1
Share this question
or