protected override void InitControl() { if (IsDesignTime) { this.ViewModel = new ViewModelHUDNotificationControl(); return; } this.storyboardShow = this.GetResource <Storyboard>("StoryboardShow"); this.storyboardHide = this.GetResource <Storyboard>("StoryboardHide"); this.storyboardFadeOut = this.GetResource <Storyboard>("StoryboardFadeOut"); this.root = this.GetByName <Border>("Border"); this.DataContext = this.ViewModel; }
protected override void OnUnloaded() { if (IsDesignTime) { return; } this.DataContext = null; this.ViewModel.Dispose(); this.ViewModel = null; this.storyboardFadeOut.Completed -= this.StoryboardFadeOutCompletedHandler; this.storyboardHide.Completed -= this.StoryboardHideCompletedHandler; this.root.MouseLeftButtonDown -= this.RootMouseButtonLeftHandler; this.root.MouseRightButtonDown -= this.RootMouseButtonRightHandler; this.root.MouseEnter -= this.RootMouseEnterHandler; this.root.MouseLeave -= this.RootMouseLeaveHandler; // to ensure that the control has a hiding flag (used for ClientComponentNotificationAutoHideChecker) this.IsHiding = true; }