diff --git a/source/Components/AvalonDock/Controls/LayoutAnchorSideControl.cs b/source/Components/AvalonDock/Controls/LayoutAnchorSideControl.cs
index c955ba79..e0453eed 100644
--- a/source/Components/AvalonDock/Controls/LayoutAnchorSideControl.cs
+++ b/source/Components/AvalonDock/Controls/LayoutAnchorSideControl.cs
@@ -1,4 +1,4 @@
-/************************************************************************
+/************************************************************************
AvalonDock
Copyright (C) 2007-2013 Xceed Software Inc.
@@ -46,11 +46,6 @@ static LayoutAnchorSideControl()
internal LayoutAnchorSideControl(LayoutAnchorSide model)
{
_model = model ?? throw new ArgumentNullException(nameof(model));
- CreateChildrenViews();
- _model.Children.CollectionChanged += OnModelChildrenCollectionChanged;
- UpdateSide();
-
- Unloaded += LayoutAnchorSideControl_Unloaded;
}
#endregion Constructors
@@ -137,11 +132,27 @@ internal LayoutAnchorSideControl(LayoutAnchorSide model)
#region Private Methods
- ///
- /// Executes when the element is removed from within an element tree of loaded elements.
- ///
- ///
- ///
+ public override void OnApplyTemplate()
+ {
+ base.OnApplyTemplate();
+
+ Loaded += LayoutAnchorSideControl_Loaded;
+ }
+
+ protected override void OnInitialized(EventArgs e)
+ {
+ base.OnInitialized(e);
+ CreateChildrenViews();
+ UpdateSide();
+ }
+
+ private void LayoutAnchorSideControl_Loaded(object sender, RoutedEventArgs e)
+ {
+ Loaded -= LayoutAnchorSideControl_Loaded;
+ Unloaded += LayoutAnchorSideControl_Unloaded;
+ _model.Children.CollectionChanged += OnModelChildrenCollectionChanged;
+ }
+
private void LayoutAnchorSideControl_Unloaded(object sender, RoutedEventArgs e)
{
_model.Children.CollectionChanged -= OnModelChildrenCollectionChanged;