ContextMenu Add items where expand

2 posts, 0 answers
  1. Andrey
    Andrey avatar
    1 posts
    Member since:
    Oct 2012

    Posted 11 Oct 2012 Link to this post

    in XAML: 

        <telerik:RadMenuItem Header="Sub Item 1"/>
                    <telerik:RadMenuItem Header="Sub Item 2" Style="{StaticResource RadContextMenuItemStyle}" ItemsSource="{Binding Groups}"
                                           MouseEnter="RadMenuItem_MouseEnter" Loaded="RadMenuItem_Loaded" Name="cont">
                            <Style       TargetType="telerik:RadMenuItem">
                                <Setter Property="Header"            Value="{Binding Name}" />
                                <Setter Property="IsSeparator"            Value="{Binding IsSeparator}" />
                                <Setter Property="CommandParameter" Value="{Binding Id}"/>
                    <telerik:RadMenuItem Header="Item 2" ItemsSource="{Binding Groups}"/>

    in xaml.cs:

            private void RadMenuItem_MouseEnter(object sender, MouseEventArgs e)

            private void FillMethod()
                if (!f)
                    this.Dispatcher.BeginInvoke(() =>
                                                        var viewmodel =
            private bool f = false;
            private void RadMenuItem_Loaded(object sender, RoutedEventArgs e)
                f = false;

    in viewmodel:
            protected virtual void InvokePopup(object obj)
                Groups = new List<Group>();
                Groups.Add(new Group {Name = "Loading...",Id = "---"});

            public MainPageViewModel()
                fillservice = new MockFill();
                fillservice.Completeevent += FillContextMenuMethod;
                ActionCommand = new DelegateCommand<object>(InvokeAction,CanInvokeAction);
                PopupCommand = new DelegateCommand<object>(InvokePopup, CanInvokePopup);
                Groups = new List<Group>();
                Groups.Add(new Group {Name = "Loading...",Id = "---"});


            private void FillContextMenuMethod(object sender, GroupsEventArgs e)
                UIDispatcher.BeginInvoke(() =>
                    Groups = e.Groups.ToList();

    Context menu have a bad behavior, where i change my property group where, submenu is expanding(all arrows had collapsed
    for 1-3 seconds and submenu collapsed)
  2. Rosen Vladimirov
    Rosen Vladimirov avatar
    648 posts

    Posted 16 Oct 2012 Link to this post

    Hi Andrey,

    We have tried such scenario and we have set a solution for you. The problem is that if you try to remove all items in the collection, the RadContextMenu will close the popup as it doesn't have what to show. Meanwhile you are adding some items and this is causing the confusion.
    In our simple application we are using Dispatcher to add items dynamically, but we remove all not needed items after we've added the new Groups.

    Please check the attachment and inform us if you still have any concerns.

    All the best,
    Rosen Vladimirov
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top