RibbonWindow Unload event

Ribbon for WPF Forum

Posted 14 years ago by cowcow
Version: 10.1.0522
Avatar
Hi,

I am trying to Serialize the RecentDocument to file when the user exist the application.

However, I find that the RibbonWindow_Unloaded is not triggered when the application exit.

Here is my MainWindow:
<ribbon:RibbonWindow x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
.....


Here is my Unloaded function:
Private Sub RibbonWindow_Unloaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Unloaded
WriteRecentDocToFile()
MsgBox("Unload Ribbon")
End Sub

I also tried to put the Unloaded="RibbonWindow_Unloaded" to RibbonWindow , but I got no luck.

Did i miss anything, please advise.

Thanks,
Cow.

Comments (5)

Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi,

I did a test and Unloaded is firing ok for us in the main Ribbon demo. We attach to the event in RibbonWindow itself, but don't set e.Handled, so it should be firing for you too.


Actipro Software Support

Posted 14 years ago by cowcow
Avatar
Thank you for you reply.
Let me create a new project and test it again.

BTW, could you please let me know how to capture the event when the user pin/un-pin the document in the RecentDocument menu?

Thanks,
Cow
Posted 14 years ago by cowcow
Avatar
I tested it again in VS2010 with the following simplified code, but it's not working.
When I exit the application, it couldn't see the popup (MsgBox("Unloading"))


File: MainWindow.xaml

<ribbon:RibbonWindow x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ribbon="http://schemas.actiprosoftware.com/winfx/xaml/ribbon"
Title="MainWindow" Height="600" Width="800"
WindowStartupLocation="CenterScreen">
<ribbon:Ribbon />
</ribbon:RibbonWindow>



File: MainWindow.xaml.vb

Class MainWindow
Private Sub RibbonWindow_Unloaded(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles MyBase.Unloaded
MsgBox("Unloading")
End Sub
End Class
Posted 14 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Odd, in another smaller test project I can't get it to fire either. I did some googling and it appears to be a general WPF thing. Window.Unloaded won't reliably fire when an app shuts down. In my first test on Friday, the RibbonWindow I watched was not the main app window, and it does fire there since the app shutdown isn't occurring. This explains it:
http://social.msdn.microsoft.com/forums/en-US/wpf/thread/e7a371dc-48af-4292-b1b4-2bd4459b4a00

Regardless though you should be serializing information like recent documents in the Closing event of the Window instead.

I don't believe there is a notification when the pin is clicked at this time since it is intended that you just serialize the list out on window close.


Actipro Software Support

Posted 14 years ago by cowcow
Avatar
Thanks.
The latest build of this product (v24.1.2) was released 2 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.