예제 #1
0
        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);
            }
        }
예제 #2
0
        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);
            }
        }