diff options
author | Eric Maupin <ermaup@microsoft.com> | 2019-01-15 01:01:03 +0300 |
---|---|---|
committer | Eric Maupin <ermaup@microsoft.com> | 2019-02-15 20:35:53 +0300 |
commit | dcac85f184a7fce4297904358ab2099efc031da8 (patch) | |
tree | 3d783b2ad673a5c440e0b6d144dcccc80e284aeb /Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs | |
parent | 38ea4489eaf0b4b8975e65527ff59b35c29875de (diff) |
[mac] ViewModel is allowed to be null
Diffstat (limited to 'Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs')
-rw-r--r-- | Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs index efa2171..5b33084 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/PropertyEditorControl.cs @@ -32,9 +32,9 @@ namespace Xamarin.PropertyEditing.Mac PropertyViewModel viewModel; public PropertyViewModel ViewModel { - get { return viewModel; } + get { return this.viewModel; } set { - if (viewModel == value) + if (this.ViewModel == value) return; PropertyViewModel oldModel = this.viewModel; @@ -45,10 +45,10 @@ namespace Xamarin.PropertyEditing.Mac this.viewModel = value; OnViewModelChanged (oldModel); - viewModel.PropertyChanged += OnPropertyChanged; - - // FIXME: figure out what we want errors to display as (tooltip, etc.) - viewModel.ErrorsChanged += HandleErrorsChanged; + if (this.viewModel != null) { + this.viewModel.PropertyChanged += OnPropertyChanged; + this.viewModel.ErrorsChanged += HandleErrorsChanged; + } } } @@ -103,11 +103,12 @@ namespace Xamarin.PropertyEditing.Mac protected virtual void OnViewModelChanged (PropertyViewModel oldModel) { - SetEnabled (); - UpdateValue (); - UpdateAccessibilityValues (); + if (ViewModel != null) { + SetEnabled (); + UpdateValue (); + UpdateAccessibilityValues (); + } - // Hook this up so we know when to reset values PropertyButton.ViewModel = viewModel; } |