Prevent closing of the Backstage

11 posts, 0 answers
  1. Michael
    Michael avatar
    8 posts
    Member since:
    Nov 2008

    Posted 25 Jun 2014 Link to this post

    Is there a way to prevent the closing of the Backstage until a condition is true. So if the user clicks on another tab, I would like to keep it open.

  2. Milena
    Admin
    Milena avatar
    204 posts

    Posted 26 Jun 2014 Link to this post

    Hello Michael,

    You can achieve such behavior by using PreviewSelectionChanged and SelectionChanged events of the RadRibbonView. On PreviewSelectionChange you can check if the backstage is open (through the IsBackStageOpen property of the RadRibbonView) and then keep it open until the ApplicationMenuButton isn't pressed:  

    bool isBackstageOpen = false;
     
    private void radRibbonView_PreviewSelectionChanged(object sender, Telerik.Windows.Controls.RadSelectionChangedEventArgs e)
    {
        var ribbon = (sender as RadRibbonView);
        isBackstageOpen = ribbon.IsBackstageOpen;     
    }    
     
    private void RadRibbonView_SelectionChanged(object sender, RadSelectionChangedEventArgs e)
    {
        var ribbon = (sender as RadRibbonView);
        if (isBackstageOpen)
        {
            ribbon.IsBackstageOpen = true;
        }
    }
    I hope this information will help you and don't hesitate to write back if you have more questions.


    Regards,
    Milena
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Michael
    Michael avatar
    8 posts
    Member since:
    Nov 2008

    Posted 26 Jun 2014 in reply to Milena Link to this post

    I'm getting this error 

    A first chance exception of type 'System.InvalidOperationException' occurred in PresentationFramework.dll

    Additional information: Specified element is already the logical child of another element. Disconnect it first.

    on the line:

    ribbon.IsBackstageOpen = true;
  5. Milena
    Admin
    Milena avatar
    204 posts

    Posted 27 Jun 2014 Link to this post

    Hello Michael,

    I have tried to reproduce the exception (using binaries from our last release - 2014.2 617 as you) but to no avail. However I attached the test project I used to reproduce the issue. Please feel free to modify it in order to show us how to reproduce it. This will allow us to investigate the problem further.

    Thank you for your understanding and cooperation in advance.

    Regards,
    Milena
    Telerik
     
    Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
     
  6. Gord
    Gord avatar
    20 posts
    Member since:
    Jul 2014

    Posted 19 Jul in reply to Milena Link to this post

    I realize this is an older post, but I am trying to do something similar.  Following the direction here works if there are other tabs loaded.  However, if there is only the application button and no other tabs, the PreviewSelectionChanged event does not get fired.   Is the only way to prevent the backstage from closing, to put a dummy placeholder tab in so that the selectionChanged event can fire?
  7. Milena
    Admin
    Milena avatar
    204 posts

    Posted 20 Jul Link to this post

    Hi Gord,

    PreviewSelectionChanged and SelectionChanged events are raised when the tab selection is about to be done or is done. If you don't have any RibbonTabs in RibbonView, then the events will not be fired. You can find more information in our help article Ribbon Tab in section Events

    However, I'm not sure that I understand your scenario. Could you please send us more detailed information about it - a sample project, a code-snippet of your RibbonView, steps - when the backstage closes, etc. 

    Thank you in advance for your cooperation. 

    Regards,
    Milena
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  8. Gord
    Gord avatar
    20 posts
    Member since:
    Jul 2014

    Posted 20 Jul Link to this post

    I have an application that loads a single object for editing.  When loaded, based on the configuration information in the object, different tabs are displayed in the ribbon bar.  When no object is loaded, the ribbon bar is completely empty.  In that situation, I want to keep the backstage open so the user is not presented with an empty screen.

    I did some tests.  I set the boolean for keeping the backstage open in the preSelectionChanged event, and then set it to shown in the SelectionChanged (with placing a dummy tab to trigger the change events), as outlined above.  When I click the "back" button that closes the backstage, the UI thread locks up. I assume there is some kind of recusive loop occurring because the "IsBackstageOpen" is getting set after the change happens.

     

    Would the only solution for this be to create a static class with a "CloseBackstage" command in it, and override the existing command reference in the RadRibbonBackstage control template?

  9. Milena
    Admin
    Milena avatar
    204 posts

    Posted 22 Jul Link to this post

    Hello Gord,

    Thank you for the additional information. I tried to follow your scenario, but I cannot reproduce the issue. However, I might be missing important part of your implementation (e.g. what do you mean by "dummy tab"). This is why I believe it will be better if you send us a sample project with steps to reproduce. This will allow us to examine your implementation and try to reproduce the issue locally. We can then modify the solution to work per your requirements and send it back to you.

    Also you wrote "ribbon bar", I suppose you mean RadRibbonView control? Could you tell us which version of our UI for WPF you are using? 

    I'm looking forward for helping you solve this issue.

    Regards,
    Milena
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  10. Gord
    Gord avatar
    20 posts
    Member since:
    Jul 2014

    Posted 22 Jul in reply to Milena Link to this post

    Hello Milena,

    I wasn't able to upload the project here.  It says the file was either too large or not the allowed type.  I have uploaded it to a dropbox account instead:  Sample.zip

    It has a RibbonView with an application button, and one tab.  In the SelectionChanged event, it checks if an internal data object is null, and if it is, it sets the "IsBackstageOpen" property to true, to keep it open.

    This tab serves no purpose aside from its existence triggering the SelectionChanged event, which is why I referred to it as a "dummy tab".  When hitting escape, or clicking the back arrow in the backstage, the UI freezes.

    I am currently using version 2016.1.217, which is a bit out of date.  If upgrading resolves this, then that's a simple solution.

    The other problem I had mentioned is that, ideally, I don't want to have to use a placeholder tab when no data is loaded, just to handle keeping the backstage open. 

    To address this issue, what I have done is changed the reference to "telerik:RibbonCommands.CloseBackstage" in the RadRibbonBackstage template that I extracted, for the close button, to reference my own custom implementation through a static class, in which it can check if my view model is null or not, and prevent closing. This works fine for the button click, however, the escape key still closes the backstage.  Is this because the original RibbonCommands.CloseBackstage has a keybinding to Key.Escape? 

  11. Kiril Vandov
    Admin
    Kiril Vandov avatar
    324 posts

    Posted 27 Jul Link to this post

    Hello Gord,

    About the UI lock issue we are aware of that and as you have find out changing the command for the close button is currently the only solution for it. The problem is that the command is already executed in the SelectionChanged event and the RibbonView is closing the Backstage (however it still holding resources which are not released as the UnloadedEvent is still not fired). Then we try to open the backstage before the unloaded and that is why the UI freezes.

    The Escape key is designed to close the Backstage by default. This logic comes from the Backstage itself and is not executed via command. In order to remove that default behavior you will need to:
    - create a CustomBackstage class
    - make the class inherit from our RadRibbonBackstage
    - override the HandleKey method, and in the override don\t call the base.HandleKey() (leave the method empty).

    Doing so you will be able to forbid the clients from closing the Backstage when the EscapeKey is pressed.

    I hope this information helps.

    Regards,
    Kiril Vandov
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  12. Gord
    Gord avatar
    20 posts
    Member since:
    Jul 2014

    Posted 27 Jul in reply to Kiril Vandov Link to this post

    Hello Kiril,

    Thank you.  That was the last piece of the puzzle I was missing. 

Back to Top
UI for WPF is Visual Studio 2017 Ready