diff options
author | Eric Maupin <ermaup@microsoft.com> | 2018-03-23 20:18:07 +0300 |
---|---|---|
committer | Eric Maupin <ermaup@microsoft.com> | 2018-03-23 20:18:07 +0300 |
commit | c67e3f14b30d91f804937e6261ae6235b00059c9 (patch) | |
tree | 1b9982805e37846f55d11b900cfacda9d1a043e7 /Xamarin.PropertyEditing | |
parent | 1b7362132a466acd37b5841e6ce4683b1d1bc08d (diff) |
[Core/Win] Add Convert to Local Value
Diffstat (limited to 'Xamarin.PropertyEditing')
-rw-r--r-- | Xamarin.PropertyEditing/ViewModels/PropertyViewModel.cs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Xamarin.PropertyEditing/ViewModels/PropertyViewModel.cs b/Xamarin.PropertyEditing/ViewModels/PropertyViewModel.cs index dfd0b70..2c3d12a 100644 --- a/Xamarin.PropertyEditing/ViewModels/PropertyViewModel.cs +++ b/Xamarin.PropertyEditing/ViewModels/PropertyViewModel.cs @@ -29,6 +29,7 @@ namespace Xamarin.PropertyEditing.ViewModels SetValueResourceCommand = new RelayCommand<Resource> (OnSetValueToResource, CanSetValueToResource); ClearValueCommand = new RelayCommand (OnClearValue, CanClearValue); + ConvertToLocalValueCommand = new RelayCommand(OnConvertToLocalValue, CanClearToLocalValue); RequestCurrentValueUpdate(); } @@ -217,6 +218,7 @@ namespace Xamarin.PropertyEditing.ViewModels OnValueChanged (); SignalValueChange(); + ((RelayCommand) ConvertToLocalValueCommand)?.ChangeCanExecute (); ((RelayCommand) ClearValueCommand)?.ChangeCanExecute (); return true; @@ -255,6 +257,19 @@ namespace Xamarin.PropertyEditing.ViewModels return (ValueSource != ValueSource.Default && ValueSource != ValueSource.Unset && ValueSource != ValueSource.Unknown); } + private bool CanClearToLocalValue () + { + return (ValueSource != ValueSource.Local && ValueSource != ValueSource.Unset); + } + + private void OnConvertToLocalValue () + { + SetValue (new ValueInfo<TValue> { + Value = Value, + Source = ValueSource.Local + }); + } + private static TValue DefaultValue; } @@ -353,6 +368,12 @@ namespace Xamarin.PropertyEditing.ViewModels protected set; } + public ICommand ConvertToLocalValueCommand + { + get; + protected set; + } + public bool HasErrors => this.error != null; public IEnumerable GetErrors (string propertyName) |