Fluent.Ribbon icon indicating copy to clipboard operation
Fluent.Ribbon copied to clipboard

Cancel backstage close event

Open lilhoser opened this issue 7 months ago • 3 comments

Is there a way to do cancel a backstage close event? I only see IsOpenChanged which does not allow setting e.Cancel on the event in question. The use case is a delayed operation on a form in the backstage needing to complete.

lilhoser avatar Apr 15 '25 14:04 lilhoser

Currently there is no way to do so. But it sounds like a good addition.

batzen avatar Apr 16 '25 07:04 batzen

Just had a look at the code and you can prevent closing the Backstage already.

Just set CanChangeIsOpen to false to prevent the Backstage from being closed during your delayed operation.

Would be nice if you could report back if that worked in your situation.

batzen avatar May 29 '25 06:05 batzen

I'm not sure that quite solves my scenario, because I need to cancel a backstage close operation in progress, not just prevent one from happening. Ie, from this location:

private void Backstage_IsOpenChanged(object sender, System.Windows.DependencyPropertyChangedEventArgs e)
{
    var newvalue = (bool)e.NewValue;
    var oldvalue = (bool)e.OldValue;
    if (oldvalue && !newvalue)
    {

The scenario is that closing the backstage triggers a form being saved, as it indicates the user is done changing values. I suppose I could find another trigger point.

lilhoser avatar May 29 '25 14:05 lilhoser