-1

In the user control(this is not my code), I have found part of code that I don't understand why to use Independent and not a dependency property. Can someone please explain.Thanks

 <Label Content="{Binding Flow, UpdateSourceTrigger=PropertyChanged, Mode=OneWay}" ContentStringFormat="{}{0:N1}" />

ViewModel

 private Independent<double> _flow = new Independent<double>(10.567);
    public double Flow
    {
        get { return _flow; }
        private set { _flow.Value = value; }
    }
leapold
  • 133
  • 1
  • 10

1 Answers1

0

Well, usually dependency properties are in custom controls' code behind, not in view models. And usually you want your properties in a view model to implement INotifyPropertyChanged. There is no OnPropertyChanged or similar call in this property setter, so it's probably what the setter of the Value property in Independent<double> does.

I guess Independent<T> is a wrapper class that raises OnPropertyChanged and does some other stuff, like a viewmodel property base class. Look at the ValueViewModel class mentioned here as an example.

Community
  • 1
  • 1
mechanic
  • 761
  • 6
  • 11