diff options
6 files changed, 34 insertions, 24 deletions
diff --git a/Xamarin.PropertyEditing.Mac/Controls/CombinablePropertyEditor.cs b/Xamarin.PropertyEditing.Mac/Controls/CombinablePropertyEditor.cs index cf58bdc..f7974e6 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/CombinablePropertyEditor.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/CombinablePropertyEditor.cs @@ -58,6 +58,11 @@ namespace Xamarin.PropertyEditing.Mac protected override void OnViewModelChanged (PropertyViewModel oldModel) { + base.OnViewModelChanged (oldModel); + + if (ViewModel == null) + return; + nint rowHeight = GetHeight (ViewModel); float top = checkHeight; @@ -99,9 +104,6 @@ namespace Xamarin.PropertyEditing.Mac // Set our tabable order this.firstKeyView = this.combinableList.KeyAt (0); this.lastKeyView = this.combinableList.KeyAt (this.combinableList.Count - 1); - - base.OnViewModelChanged (oldModel); - } protected override void UpdateValue () diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs index dd63955..dc956e3 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/BrushTabViewController.cs @@ -58,7 +58,7 @@ namespace Xamarin.PropertyEditing.Mac this.inhibitSelection = true; base.OnViewModelChanged (oldModel);
- var existing = new HashSet<CommonBrushType> (ViewModel?.BrushTypes?.Values ?? Array.Empty<CommonBrushType> ());
+ var existing = new HashSet<CommonBrushType> (oldModel?.BrushTypes?.Values ?? Array.Empty<CommonBrushType> ());
existing.IntersectWith (this.brushTypeTable.Keys);
var removed = new HashSet<CommonBrushType> (this.brushTypeTable.Keys);
diff --git a/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs b/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs index fab17c6..9846e2c 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/Custom/PropertyButton.cs @@ -18,14 +18,15 @@ namespace Xamarin.PropertyEditing.Mac { get { return viewModel; } set { - if (viewModel != null) { - viewModel.PropertyChanged -= OnPropertyChanged; + if (this.viewModel != null) { + this.viewModel.PropertyChanged -= OnPropertyChanged; } - viewModel = value; - viewModel.PropertyChanged += OnPropertyChanged; - - ValueSourceChanged (viewModel.ValueSource); + this.viewModel = value; + if (this.viewModel != null) { + this.viewModel.PropertyChanged += OnPropertyChanged; + ValueSourceChanged (this.viewModel.ValueSource); + } } } diff --git a/Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs index e6b1277..e15e206 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/NumericEditorControl.cs @@ -133,6 +133,11 @@ namespace Xamarin.PropertyEditing.Mac protected override void OnViewModelChanged (PropertyViewModel oldModel) { + base.OnViewModelChanged (oldModel); + + if (ViewModel == null) + return; + if (ViewModel.HasInputModes) { if (this.inputModePopup == null) { this.inputModePopup = new NSPopUpButton { @@ -169,8 +174,6 @@ namespace Xamarin.PropertyEditing.Mac // If we are reusing the control we'll have to hid the inputMode if this doesn't have InputMode. if (this.inputModePopup != null) this.inputModePopup.Hidden = !ViewModel.HasInputModes; - - base.OnViewModelChanged (oldModel); } } } 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; } diff --git a/Xamarin.PropertyEditing.Mac/Controls/StringEditorControl.cs b/Xamarin.PropertyEditing.Mac/Controls/StringEditorControl.cs index 75f46d4..ee32d25 100644 --- a/Xamarin.PropertyEditing.Mac/Controls/StringEditorControl.cs +++ b/Xamarin.PropertyEditing.Mac/Controls/StringEditorControl.cs @@ -65,6 +65,11 @@ namespace Xamarin.PropertyEditing.Mac protected override void OnViewModelChanged (PropertyViewModel oldModel) { + base.OnViewModelChanged (oldModel); + + if (ViewModel == null) + return; + if (ViewModel.HasInputModes) { if (this.inputModePopup == null) { this.inputModePopup = new NSPopUpButton { @@ -101,8 +106,6 @@ namespace Xamarin.PropertyEditing.Mac // If we are reusing the control we'll have to hid the inputMode if this doesn't have InputMode. if (this.inputModePopup != null) this.inputModePopup.Hidden = !ViewModel.HasInputModes; - - base.OnViewModelChanged (oldModel); } protected override void UpdateErrorsDisplayed (IEnumerable errors) |