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

ContextMenu with CheckBox

3 Answers 175 Views
ContextMenu
This is a migrated thread and some comments may be shown as answers.
Ivan
Top achievements
Rank 1
Ivan asked on 10 Feb 2014, 11:17 AM
Hello,

i'm going to build a RadContextMenu and set the ItemSource with the Columns of a RadGridView.
The task is to show a list of names of columns and a CheckBox in front of them to set the Visibility of columns.
But i can not show the CheckBox in my project.
I followed Binding to Dynamic Data and tried the code in definition of RadGridView like this:

<telerik:RadContextMenu.ContextMenu>
  <telerik:RadContextMenu Opened="RadContextMenu_Opened" Opening="RadContextMenu_OnOpening">
    <telerik:RadContextMenu.ItemContainerStyle>
      <Style TargetType="telerik:RadMenuItem">
        <Setter Property="Visibility" Value="{Binding IsReorderable, Converter={StaticResource BooleanToVisibilityConverter}}"/>
        <Setter Property="Header" Value="{Binding Header}"/>
        <Setter Property="Icon" Value="{Binding IsVisible}"/>
        <Setter Property="IconTemplate">
          <Setter.Value>
            <DataTemplate>
              <CheckBox IsChecked="{Binding}"/>
            </DataTemplate>
          </Setter.Value>
        </Setter>
      </Style>
    </telerik:RadContextMenu.ItemContainerStyle>
  </telerik:RadContextMenu>
</telerik:RadContextMenu.ContextMenu>

Is there something wrong in my code?
Thank for any help.

Ivan

3 Answers, 1 is accepted

Sort by
0
Ivan
Top achievements
Rank 1
answered on 10 Feb 2014, 11:28 AM
addition:
I also tried the another standard way. But that helped neither.
<Setter Property="IsCheckable" Value="True"/>
<Setter Property="IsChecked" Value="{Binding IsVisible}"/>

Both of them get the ItemSource using the function RadContextMenu_OnOpening
private void RadContextMenu_OnOpening(object sender, RadRoutedEventArgs e)
{
  var menu = sender as RadContextMenu;
  menu.ItemsSource = this.radGridView.Columns;
}

p.s. Post can not be edited now?
0
Ivan
Top achievements
Rank 1
answered on 10 Feb 2014, 04:47 PM
ok.... i found the error.

I'm using Telerik - NoXaml. I should give the style a right base style with RadMenuItemStyle.

Sorry for that.

Regard,

Ivan
0
Accepted
Kalin
Telerik team
answered on 12 Feb 2014, 11:22 AM
Hi Ivan,

We are glad you have managed to resolve the issue.

If you have any other questions let us know.

Regards,
Kalin
Telerik

Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

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