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

Always a tab and never a Backstage ?

9 Answers 107 Views
RibbonView and RibbonWindow
This is a migrated thread and some comments may be shown as answers.
Barry
Top achievements
Rank 1
Barry asked on 19 Jul 2019, 04:06 PM

        private void RadRibbonView_SelectionChanged(object sender, RadSelectionChangedEventArgs e)
        {

              if (ribbon.SelectedItem is RadRibbonTab)
                {
                    //keepBackstageOpen = false;
                    //MasterRadRibbonView.IsBackstageOpen = false;
                    System.Diagnostics.Debug.WriteLine("RadRibbonTab");
                }
                else if (ribbon.SelectedItem is RadRibbonBackstage)
                {
                    //keepBackstageOpen = true;
                    //MasterRadRibbonView.IsBackstageOpen = true;
                    System.Diagnostics.Debug.WriteLine("RadRibbonBackstage");
                }

        }

 

If I click on the backstage, this always triggers as a tab (the last one selected), and not as the backstage...which is causing me many problems.

Any advice ?

9 Answers, 1 is accepted

Sort by
0
Barry
Top achievements
Rank 1
answered on 19 Jul 2019, 04:09 PM

Also, it reports the Backstage as not visible (even though I'm looking right at it)...cause it wants to go to the previously selected tab. The short end of it is, I need to be able to keep the backstage visible when I want to, and go to a tab when I want to - from codebehind.

0
Dilyan Traykov
Telerik team
answered on 23 Jul 2019, 09:26 AM
Hi Barry,

The button which activates the ribbonview's backstage is not technically a part of the RadRibbonTabStrip panel and once it is selected, the SelectionChanged of the RadRibbonView control should return null as the SelectedItem. I've prepared a small sample project where this is the case at my end. In addition, the IsBackstageOpen property is true in this case.

Can you please have a look at the attached project and let me know how it differs from the setup at your end? I will be awaiting your reply.

Regards,
Dilyan Traykov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Barry
Top achievements
Rank 1
answered on 23 Jul 2019, 02:45 PM

Thank you for taking the time to throw together an example, however it's not quite the same as our scenario:

*In the XAML (binding to VM):*

<telerik:RadRibbonBackstageItem x:Name="BackstageItem_Exit" Header="{x:Static properties:Resources.ExitMenuLabel}"  Command="{Binding ExitCommand}" IsSelectable="False" Icon="..\..\Images\IMG_EXIT.png"/>

 

*MainViewModel.cs:*

 

        public void ExecuteExitCommand()
        {

                MessageBoxManager.Unregister();
                MessageBoxManager.Register();
                MessageBoxManager.Backup();
                MessageBoxManager.OK = Properties.Resources.General_Discard;

                var result = MessageBox.Show(unsavedChangesMsg, Properties.Resources.MessageBoxTitle_Confirmation, MessageBoxButton.OKCancel, MessageBoxImage.Question);

                MessageBoxManager.Restore();

                if (result == MessageBoxResult.OK)
                {
                    Application.Current.Shutdown();
                }
                else if(result == MessageBoxResult.Cancel)
                {
                    *//WE GET THROWN OUT OF THE BACKSTAGE HERE !*
                }

}

 

When the cancel button for the MessageBox is pressed, the user is thrown back to the last tab used, and the backstage closes. We need them to stay in the backstage, as they wanted to be there (and we have other links they may want to use).

0
Barry
Top achievements
Rank 1
answered on 23 Jul 2019, 03:06 PM

It's also worth mentioning that after the the Cancel button in our pop-up is pressed, when the *RadRibbonView_SelectionChanged* is hit, the ribbon is reporting that the Backstage is already closed...which makes it difficult to wire in a work-around.

We need to know that the user was in the backstage, we got to an event handler of some kind after the cancel button was pressed (RadRibbonView_SelectionChanged) works for me....and then force the backstage to remain open; ribbon.IsBackstageOpen = true;

0
Dilyan Traykov
Telerik team
answered on 24 Jul 2019, 10:10 AM
Hello Barry,

Thank you very much for the clarification and the provided code snippet.

When the backstage item's IsSelectable property is set to False, you're able to take advantage of the Click event of the item, as well as its Command property, however, it will behave like a button and the backstage will get closed. What I can suggest in order to achieve the desired behavior and still be able to bind the ExitCommand is to make the item selectable and use the EventToCommandBehavior to bind the ExitCommand to the MouseLeftButtonUp event, for example.

<telerik:RadRibbonBackstageItem Header="Exit">
    <telerik:EventToCommandBehavior.EventBindings>
        <telerik:EventBinding EventName="MouseLeftButtonUp" Command="{Binding ExitCommand}" RaiseOnHandledEvents="True" />
    </telerik:EventToCommandBehavior.EventBindings>
</telerik:RadRibbonBackstageItem>

I've updated the sample project to demonstrate this approach. Please have a look and let me know if this would work for you.

Regards,
Dilyan Traykov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Barry
Top achievements
Rank 1
answered on 24 Jul 2019, 03:05 PM

Hi !

Your solution did indeed keep me in the backstage, however the loaded content was blown away. I was looking at our "About" page, and then pressed the Exit button...the about page content vanished. We're getting closer though it feels. [see attached]

0
Barry
Top achievements
Rank 1
answered on 24 Jul 2019, 03:27 PM

I think I got it....a combination of your XAML approach and some code-behind to track what they were looking at (BackstageItem) and then re-selecting it again:

<telerik:RadRibbonBackstageItem x:Name="BackstageItem_About" Header="{x:Static properties:Resources.AboutMenuLabel}" IsSelectable="True" IsDefault="True">

...so if they were looking at that when the pressed the "exit" button, then in code-behind:

BackstageItem_About.IsSelected = true;

..and that brough it back.

I think we got it !!! :-)

0
Accepted
Dilyan Traykov
Telerik team
answered on 25 Jul 2019, 10:45 AM
Hi Barry,

I'm happy to hear that you've found a solution you find suitable. I just also want to suggest an alternate approach of handling the PreviewSelectionChanged event of the RadRibbonBackstage in a similar manner:

private void Backstage_PreviewSelectionChanged(object sender, RadSelectionChangedEventArgs e)
{
    if (e.AddedItems != null && e.AddedItems.Count > 0)
    {
        var item = e.AddedItems[0] as RadRibbonBackstageItem;
        if (item.Header.ToString() == "Exit")
        {
            e.Handled = true;
        }
    }
}

I hope you find this helpful. Do let me know if I can further assist you with anything else.

Regards,
Dilyan Traykov
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Barry
Top achievements
Rank 1
answered on 25 Jul 2019, 03:53 PM
Works like a charm !...coupled with your earlier bit for the XAML....thanks !
Tags
RibbonView and RibbonWindow
Asked by
Barry
Top achievements
Rank 1
Answers by
Barry
Top achievements
Rank 1
Dilyan Traykov
Telerik team
Share this question
or