public BarView(BarViewModel vm, IDeviceService deviceService, IUIUtils uiUtils) { InitializeComponent(); _timeEnter = this.Resources["TimeLengedFadeIn"] as Storyboard; _timeLeave = this.Resources["TimeLegendFadeOut"] as Storyboard; this._vm = vm; _deviceService = deviceService; _uiUtils = uiUtils; this.DataContext = vm; vm.MyDispatcher = Dispatcher.CurrentDispatcher; vm.PropertyChanged += Vm_PropertyChanged; this.MouseDoubleClick += BarView_MouseDoubleClick; this.MouseRightButtonUp += BarView_MouseRightButtonUp; this.MouseUp += BarView_MouseUp; this.Closed += BarView_Closed; this.Loaded += BarView_Loaded; this.MouseEnter += BarView_MouseEnter; this.MouseLeave += BarView_MouseLeave; }
private void BarView_Closed(object sender, EventArgs e) { _vm.Dispose(); _vm = null; }