Comment déclencher l'événement Unload de Usercontrol dans une fenêtre WPF

J'ai un UserControl dans WPF:

<UserControl x:Class="XLogin.DBLogin"
             x:Name="DBLoginUserFrame"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             mc:Ignorable="d"
             Height="263"
             Width="353"
             Loaded="DBLoginUserFrame_Loaded"
             Unloaded="DBLoginUserFrame_Unloaded">
  <Grid>
    <GroupBox Header="Database Connection"
              HorizontalAlignment="Left"
              Height="243"
              Margin="10,10,0,0"
              VerticalAlignment="Top"
              Width="333">
      <Grid>
        <TextBox x:Name="TextUserDB"
                 HorizontalAlignment="Left"
                 Height="20"
                 Margin="101,60,0,0"
                 TextWrapping="Wrap"
                 VerticalAlignment="Top"
                 Width="173" />
        <Label Content="Password:"
               HorizontalAlignment="Left"
               Height="24"
               VerticalAlignment="Top"
               Width="70"
               HorizontalContentAlignment="Right"
               Margin="10,85,0,0" />
        <PasswordBox x:Name="TextPasswordDB"
                     HorizontalAlignment="Left"
                     Height="20"
                     Margin="101,89,0,0"
                     VerticalAlignment="Top"
                     Width="173" />
        <Button x:Name="BtnConnect"
                Content="Connetti"
                Height="29"
                Width="123"
                Margin="101,152,97,24"
                Click="BtnConnect_Click" />
      </Grid>
    </GroupBox>

  </Grid>
</UserControl>

Quand je me Décharger de ce Contrôle, WPF élever événement DBLoginUserFrame_Unloaded que enregistrer mes paramètres et il fait un travail.

J'ai le MainWindow de WPF charge de ce contrôle de l'utilisateur, mais lorsque la fenêtre est fermée, mon usercontrol DÉCHARGER n'est pas le feu:

<Window x:Class="XLogin.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainWindow" Height="350" Width="525"
    xmlns:local="clr-namespace:XLogin" Unloaded="Window_Unloaded_1">
<Grid>
    <local:DBLogin/>
</Grid></Window>

Comment faire pour ajouter le contrôle UserControl événement Unload à MainWindow gestionnaire d'événement?

source d'informationauteur davymartu