Created
August 28, 2015 15:58
-
-
Save Grabacr07/bab0002433709ec3c199 to your computer and use it in GitHub Desktop.
.NET Framework 4.5.1 以降でビルドする場合は CurrentMetricUnit と CurrentImperialUnit の set アクセサーは public にしてください
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainWindowViewModel : ViewModel | |
{ | |
private double _metricValue, _imperialValue; | |
public ICommand ImperialUnitToMetric { get; private set; } | |
public ICommand MetricToImperialUnit { get; private set; } | |
public MetricUnit CurrentMetricUnit { get; set; } | |
public ImperialUnit CurrentImperialUnit { get; set; } | |
public double MetricValue | |
{ | |
get { return this._metricValue; } | |
set | |
{ | |
this._metricValue = value; | |
this.OnPropertyChanged(); | |
} | |
} | |
public double ImperialValue | |
{ | |
get { return this._imperialValue; } | |
set | |
{ | |
this._imperialValue = value; | |
this.OnPropertyChanged(); | |
} | |
} | |
public MainWindowViewModel() | |
{ | |
this.CurrentMetricUnit = MetricUnit.Units.First(); | |
this.CurrentImperialUnit = ImperialUnit.Units.First(); | |
this.MetricToImperialUnit = new DelegateCommand( | |
() => this.ImperialValue = this.CurrentImperialUnit.FromMetricUnit( | |
this.CurrentMetricUnit, this.MetricValue)); | |
this.ImperialUnitToMetric = new DelegateCommand( | |
() => this.MetricValue = this.CurrentMetricUnit.FromImperialUnit( | |
this.CurrentImperialUnit, this.ImperialValue)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment