I create my windows this way:
public static void CreateForm(String title, string classFullName, TypeShow typeShow, FrameworkElement positionReference, Dictionary<string, object> parameters, EventHandler<WindowClosedEventArgs> closedEvent)
{
UserControl userControl = (UserControl)Activator.CreateInstance(Type.GetType(classFullName));
userControl.HorizontalAlignment = HorizontalAlignment.Left;
userControl.VerticalAlignment = VerticalAlignment.Top;
RadWindow form = new RadWindow();
form.Content = userControl;
form.Header = title;
form.VerticalAlignment = VerticalAlignment.Center;
form.HorizontalAlignment = HorizontalAlignment.Center;
form.BorderThickness = new Thickness(1, 2, 1, 1);
form.Background = new SolidColorBrush(Colors.White);
LoadComboFilter(userControl);
//ConfigKeyDownGrid(userControl);
if (parameters != null)
{
foreach (var parameter in parameters)
{
if (userControl.GetType().GetProperty(parameter.Key) != null)
userControl.GetType().GetProperty(parameter.Key).SetValue(userControl, parameter.Value, null);
}
}
if (closedEvent != null)
form.Closed += closedEvent;
form.Opened += new RoutedEventHandler(form_Opened);
form.LostMouseCapture += new MouseEventHandler(form_LostMouseCapture);
userControl.KeyDown += new KeyEventHandler(UserControl_KeyDown);
switch (typeShow)
{
case TypeShow.Show:
form.Show();
break;
case TypeShow.ShowModal:
form.ShowDialog();
break;
case TypeShow.ShowTab:
break;
default:
form = null;
break;
}
}
private void btnAtalhoGrupoHistorico_Click(object sender, RoutedEventArgs e)
{
UIFactory.CreateForm("Grupos de Histórico", "Publisoft.UI.PesGrupoHistorico", UIFactory.TypeShow.ShowModal, this, null, FormClose);
}
void FormClose(object sender, WindowClosedEventArgs e)
{
LoadCombpGrupoHistorico();
}
...but when I click in "x" button of the window, the Closed event were not invoke!