ContextMenu with CheckBox

4 posts, 1 answers
  1. Ivan
    Ivan avatar
    43 posts
    Member since:
    Nov 2013

    Posted 10 Feb 2014 Link to this post

    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

  2. Ivan
    Ivan avatar
    43 posts
    Member since:
    Nov 2013

    Posted 10 Feb 2014 in reply to Ivan Link to this post

    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?
  3. UI for WPF is Visual Studio 2017 Ready
  4. Ivan
    Ivan avatar
    43 posts
    Member since:
    Nov 2013

    Posted 10 Feb 2014 in reply to Ivan Link to this post

    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
  5. Answer
    Kalin
    Admin
    Kalin avatar
    1207 posts

    Posted 12 Feb 2014 Link to this post

    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).

Back to Top