Always a tab and never a Backstage ?

10 posts, 1 answers
  1. Barry
    Barry avatar
    90 posts
    Member since:
    May 2016

    Posted 19 Jul Link to this post

            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 ?

  2. Barry
    Barry avatar
    90 posts
    Member since:
    May 2016

    Posted 19 Jul in reply to Barry Link to this post

    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.

  3. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    980 posts

    Posted 23 Jul Link to this post

    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.
  4. Barry
    Barry avatar
    90 posts
    Member since:
    May 2016

    Posted 23 Jul Link to this post

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

  5. Barry
    Barry avatar
    90 posts
    Member since:
    May 2016

    Posted 23 Jul in reply to Barry Link to this post

    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;

  6. Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    980 posts

    Posted 24 Jul Link to this post

    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.
  7. Barry
    Barry avatar
    90 posts
    Member since:
    May 2016

    Posted 24 Jul in reply to Dilyan Traykov Link to this post

    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]

  8. Barry
    Barry avatar
    90 posts
    Member since:
    May 2016

    Posted 24 Jul in reply to Barry Link to this post

    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 !!! :-)

  9. Answer
    Dilyan Traykov
    Admin
    Dilyan Traykov avatar
    980 posts

    Posted 25 Jul Link to this post

    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.
  10. Barry
    Barry avatar
    90 posts
    Member since:
    May 2016

    Posted 25 Jul in reply to Dilyan Traykov Link to this post

    Works like a charm !...coupled with your earlier bit for the XAML....thanks !
Back to Top