private void UserControl_Unloaded(object sender, RoutedEventArgs e) { _widgetManager.CloseWidgets(); XmlLayoutSerializer serializer = new XmlLayoutSerializer(dockingManager); using (XmlTextWriter writer = new XmlTextWriter(_layoutFile, Encoding.UTF8)) { serializer.Serialize(writer); } }