protected virtual void Cleanup() { if (this.IsCleanedUp) { return; } this.IsCleanedUp = true; // clean up events this.AssociatedObject.Loaded -= this.OnAssociatedObjectLoaded; this.AssociatedObject.Unloaded -= this.AssociatedObject_Unloaded; this.AssociatedObject.SourceInitialized -= this.OnAssociatedObjectSourceInitialized; this.AssociatedObject.StateChanged -= this.OnAssociatedObjectHandleWindowStateChanged; this.windowStyleChangeNotifier.ValueChanged -= this.OnPropertyChangedThatRequiresForceRedrawWindow; this.resizeModeChangeNotifier.ValueChanged -= this.OnPropertyChangedThatRequiresForceRedrawWindow; this.hwndSource?.RemoveHook(this.WindowProc); this.windowChrome = null; }
private void InitializeWindowChrome() { this.windowChrome = new WindowChrome(); BindingOperations.SetBinding(this.windowChrome, WindowChrome.ResizeBorderThicknessProperty, new Binding { Path = new PropertyPath(ResizeBorderThicknessProperty), Source = this }); BindingOperations.SetBinding(this.windowChrome, WindowChrome.CaptionHeightProperty, new Binding { Path = new PropertyPath(CaptionHeightProperty), Source = this }); BindingOperations.SetBinding(this.windowChrome, WindowChrome.CornerRadiusProperty, new Binding { Path = new PropertyPath(CornerRadiusProperty), Source = this }); BindingOperations.SetBinding(this.windowChrome, WindowChrome.GlassFrameThicknessProperty, new Binding { Path = new PropertyPath(GlassFrameThicknessProperty), Source = this }); BindingOperations.SetBinding(this.windowChrome, WindowChrome.UseAeroCaptionButtonsProperty, new Binding { Path = new PropertyPath(UseAeroCaptionButtonsProperty), Source = this }); BindingOperations.SetBinding(this.windowChrome, WindowChrome.IgnoreTaskbarOnMaximizeProperty, new Binding { Path = new PropertyPath(IgnoreTaskbarOnMaximizeProperty), Source = this }); }