RadialMenu IsOpen not showing menu items

1 Answer 141 Views
RadialMenu
Renier Pretorius
Top achievements
Rank 2
Iron
Iron
Iron
Renier Pretorius asked on 03 Dec 2021, 06:58 AM

Hi,

I am using the RadRadialMenu with a data-bound ItemsSource. It is a control within a grid that is always showing, i.e. not a context-menu. When showing the UserControl for the first time the menu is shown in its closed state. Clicking on the RadialMenuButton opens the menu and all menu items are shown as expected. However, setting the IsOpen property to true shows the menu in an open state, but with no menu items. The user has to click on the RadialMenuButton to close the menu and then click it again to open, which will then show the items.

Is this a bug or am I not setting something?

Regards

1 Answer, 1 is accepted

Sort by
0
Renier Pretorius
Top achievements
Rank 2
Iron
Iron
Iron
answered on 03 Dec 2021, 08:52 AM

[WORK AROUND]

Some additional context is that I create a new window with the user control containing the RadialMenu definition from a user event (double-click tray-icon). This creates a VM containing the collection of IRadialMenuItems, a View containing the RadialMenu definition setting the VM as its DataContext, and finally a new window setting its content to the view and showing the window.

The issue seems to be related to the thread on which things are happing in the application. I could get the desired user experience by setting the IsOpen to false in the definition and then add the following in the code-behind of the view


        public ConnectionLauncherView()
        {
            InitializeComponent();
            RadRadialMenu.AnimationSpeedFactor = 0.1d;
            Loaded += ConnectionLauncherView_Loaded;
        }

        private void ConnectionLauncherView_Loaded(object sender, RoutedEventArgs e)
        {
            Task.Run(() => ShowRadial());
        }

        private async Task ShowRadial()
        {
            DispatcherHelper.CheckBeginInvokeOnUI(() => radialMenu.IsOpen = true);
        }

I initally thought it might be a timing issue and awaited a delay in the ShowRadial async method, but even without the delay this works.

Not sure if there is a better way to achieve the same UX.

Martin Ivanov
Telerik team
commented on 06 Dec 2021, 01:00 PM

Thanks for sharing your solution.

Without recreating this I can't tell what exactly happens, but probably it is related to the single thread nature of WPF. Basically, all actions related to the UI should be dispatched to the main UI thread. Otherwise, an exception or timing issues may appear.

Tags
RadialMenu
Asked by
Renier Pretorius
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Renier Pretorius
Top achievements
Rank 2
Iron
Iron
Iron
Share this question
or