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

Close backstage view from within backstage view

3 Answers 159 Views
RibbonView and RibbonWindow
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 12 Oct 2015, 04:51 AM

Hi all - me again :)

Been making some good progress with the backstage view, but have hit another snag. We have defined the backstage view content as a DataTemplate, which allows us to use caliburn micro to inject views into the backstage view based on the items source (a list of menu item view models).

I would like to be able to close the backstage view from within these views. Eg, clicking cancel on a form within the backstage should close the backstage view. Currently, only the root object can do so (via the BackstageOpen binding), but don't like the idea of propagating that expression down the chain.

Any suggestions ? Basically, I want to be able to bind a cancel button to something that closes the backstage view.

3 Answers, 1 is accepted

Sort by
0
Kiril Vandov
Telerik team
answered on 12 Oct 2015, 07:49 AM
Hello Michael,

The RadRibbonView exposes a command that could be executed while the BackstageIsOpen and it is a CloseBackstageCommand. You could use that command and directly bind the button in your xaml, here is an example of how to do that:
<telerik:RadRibbonButton Command="{x:Static telerik:RibbonCommands.CloseBackstage}" Content="Close" />

 I hope this information helps.

Kind regards,
Kiril Vandov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Michael
Top achievements
Rank 1
answered on 13 Oct 2015, 05:36 AM

That's almost exactly what I want !

On close, I want to do a bit of cleanup though, so I created a CompositeCommand that was made up of the ribbon command, as well as my own command. That doesn't seem to work however. Maybe the Prism composite command doesn't like combining a RoutedUICommand with a DelegateCommand ...

I can't invoke the Ribbon command directly, as I don't know what the target is.

Is there a way I can clean up while closing ?


 
0
Kiril Vandov
Telerik team
answered on 15 Oct 2015, 11:08 AM
Hello Michael,

The CloseBackstageCommand is a standard RoutedUICommand and as all RouterUICommand it can be intersected in the static constructor of you your application. Once you intersect it you can execute your own logic. Unfortunately as the RadRibbonBackstage is not aware of its RibbonView you cant access it and close the backstage. We can consider exposing a public method in the RadRibbonBackstage whcih can trigger close. Until such logic is implemented you could either create a CustomBackstage and make the command and cleanup logic there. Or you could use the ApplicationMenuOpenStateChanged event of the RadRibbonView and clean your code if the backstage is closed.

I hope this information helps.

Regards,
Kiril Vandov
Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Chase
Top achievements
Rank 1
commented on 02 May 2023, 07:41 PM

Are you guys ever going to add this?  It's been 8 years and I could still use it.

 

Or - just tell me how to invoke the CloseBackstage Telerik Ribbon Command that is already out there.

Chase
Top achievements
Rank 1
commented on 02 May 2023, 07:45 PM | edited

FWIW: I am already invoking this in Xaml from the backstage, but in another place in my project, I need to kick it off from my viewmodel.

I just need to do it in code, something I would expect looks like this (I just don't know what to pass it, I know what it wants for the arguments, but I am invoking this myself, so the sender is ME not the control, I can just pass it the backstage that I am using in my ribbon?  What do we need to give it for the second argument to trigger this?

RibbonCommands.CloseBackstage.Execute(null, null);  <=would something like this work?  What am I to pass it?

Martin Ivanov
Telerik team
commented on 05 May 2023, 07:07 AM

There are no immediate plans to provide a public CloseBackstage method. This is mostly because, you can use the IsBackstageOpen property of the parent RadRibbonView or the CloseBackstage command.

To use the command, you need to pass the RadRibbonBackstage instance as second argument of the Execute method:

RibbonCommands.CloseBackstage.Execute(null, this.backstage);

This approach (RoutedUICommands in general) is not very suitable for usage in the view model. For that situation, I suggest you to use the IsBackstageOpen property of RadRibbonView. This will allow you to data bind it to a property in your view model, which you can set to False, in order to close the backstage. For example:

 <telerik:RadRibbonView IsBackstageOpen="{Binding IsBackstageOpen, Mode=TwoWay}"/>


public class MyViewModel : ViewModelBase
{
	private bool isBackstageOpen;

	public bool IsBackstageOpen
	{
		get { return isBackstageOpen; }
		set { isBackstageOpen = value; OnPropertyChanged(nameof(IsBackstageOpen)); }
	}

	public void CloseBackstage()
	{
		IsBackstageOpen = false;
	}
}


 

Tags
RibbonView and RibbonWindow
Asked by
Michael
Top achievements
Rank 1
Answers by
Kiril Vandov
Telerik team
Michael
Top achievements
Rank 1
Share this question
or