This project is read-only.

RestoreLayout doesn't applies template

Jul 6, 2011 at 3:55 PM

In the program I'm writing I use DocumentPane controls with a number of specific types of their content. I need to save windows layout and I use the build-in methods SaveLayout and RestoreLayout. But then I use the RestoreLayout method with the following callback:

        public static DockableContent GetWindowContentByType(WindowType _type)
        {
            switch (_type)
            {
                case WindowType.PreviewWindow:
                    return new PreviewControl();
                case WindowType.PropertyGrid:
                    return new PropertiesGridControl();
                case WindowType.ToolsPalette:
                    return new PaletteControl();
                case WindowType.SolutionExplorer:
                    return new ExplorerTreeControl();
                default: throw new InvalidOperationException();
            }
        }

        public static void DeserializationCallback(object sender, DeserializationCallbackEventArgs e)
        {
            e.Content = GetWindowContentByType((WindowType)Enum.Parse(typeof(WindowType), e.Name));
            //e.Content.HorizontalAlignment = HorizontalAlignment.Stretch;
            //e.Content.VerticalAlignment = VerticalAlignment.Stretch;
        }
although I have some content in the DocumentPanes but the controls have zero ActualWidth and ActualHeight. By the way after the layout restoring, OnApplyTemplate method neither being called. The commented lines are my attempts to fix it, but still I have no result. Nothing occurs when I try to call ApplyTemplate or OnApplyTemplate methods or something else. ActualWidth and ActualHeight are still zero. It makes my controls working not properly. Tell me please how can I restore some layout with DockableContent that has non-zero ActualWidth and ActualHeight.