private static void OnFrameworkElement_Loaded(object sender, RoutedEventArgs e) { FrameworkElement frameworkElement = sender as FrameworkElement; if (frameworkElement == null) { return; } ICommand loadLayoutCommand = AvalonDockLayoutSerializer.GetLoadLayoutCommand(frameworkElement); // There may not be a command bound to this after all if (loadLayoutCommand == null) { return; } if (loadLayoutCommand is RoutedCommand) { (loadLayoutCommand as RoutedCommand).Execute(frameworkElement, frameworkElement); } else { loadLayoutCommand.Execute(frameworkElement); } }
private static void OnFrameworkElement_Saved(object sender, RoutedEventArgs e) { DockingManager frameworkElement = sender as DockingManager; if (frameworkElement == null) { return; } ICommand SaveLayoutCommand = AvalonDockLayoutSerializer.GetSaveLayoutCommand(frameworkElement); // There may not be a command bound to this after all if (SaveLayoutCommand == null) { return; } string xmlLayoutString = ""; using (StringWriter fs = new StringWriter()) { var serializer = new XmlLayoutSerializer(frameworkElement); serializer.Serialize(fs); xmlLayoutString = fs.ToString(); } if (SaveLayoutCommand is RoutedCommand) { (SaveLayoutCommand as RoutedCommand).Execute(xmlLayoutString, frameworkElement); } else { SaveLayoutCommand.Execute(xmlLayoutString); } }