/// <summary>
        /// This method is executed when a AvalonDock <seealso cref="DockingManager"/> instance fires the
        /// Load standard (FrameworkElement) event.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void OnFrameworkElement_Loaded(object sender, RoutedEventArgs e)
        {
            var frameworkElement = sender as FrameworkElement;

            // Sanity check just in case this was somehow send by something else
            if (frameworkElement == null)
            {
                return;
            }

            var loadLayoutCommand = AvalonDockLayoutSerializer.GetLoadLayoutCommand(frameworkElement);

            // There may not be a command bound to this after all
            if (loadLayoutCommand == null)
            {
                return;
            }

            // Check whether this attached behaviour is bound to a RoutedCommand
            var command = loadLayoutCommand as RoutedCommand;

            if (command != null)
            {
                // Execute the routed command
                command.Execute(frameworkElement, frameworkElement);
            }
            else
            {
                // Execute the Command as bound delegate
                loadLayoutCommand.Execute(frameworkElement);
            }
        }
        /// <summary>
        /// This method is executed when a AvalonDock <seealso cref="DockingManager"/> instance fires the
        /// Unload standard (FrameworkElement) event.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private static void OnFrameworkElement_Saveed(object sender, RoutedEventArgs e)
        {
            DockingManager frameworkElement = sender as DockingManager;

            // Sanity check just in case this was somehow send by something else
            if (frameworkElement == null)
            {
                return;
            }

            var SaveLayoutCommand = AvalonDockLayoutSerializer.GetSaveLayoutCommand(frameworkElement);

            // There may not be a command bound to this after all
            if (SaveLayoutCommand == null)
            {
                return;
            }

            var xmlLayoutString = string.Empty;

            using (var fs = new StringWriter())
            {
                var xmlLayout = new XmlLayoutSerializer(frameworkElement);

                xmlLayout.Serialize(fs);

                xmlLayoutString = fs.ToString();
            }

            // Check whether this attached behaviour is bound to a RoutedCommand
            var command = SaveLayoutCommand as RoutedCommand;

            if (command != null)
            {
                // Execute the routed command
                command.Execute(xmlLayoutString, frameworkElement);
            }
            else
            {
                // Execute the Command as bound delegate
                SaveLayoutCommand.Execute(xmlLayoutString);
            }
        }