I have some philosophical question for you:
In my UWP apps, currently I usually define binding properties as follows:
public class ExampleViewModel : BaseBind {
// Pattern used for two-way bindings
private object exampleObject; // Private field for backing a binding propery
public Object ExampleObject {
get { return exampleObject; }
set {
SetProperty(ref exampleObject, value);
OnPropertyChanged(nameof(ExampleDerivateProperty));
}
}
// Simple derivate property, used in One-way bindings
public Object ExampleDerivateProperty => (<<Boolean function about ExampleObject>>)? "Something" : "Something different";
}
That's it... this is all that I currently use in my MVC pattern.
...but I noticed that many prefer using DependencyProperty for backing their binding properties:
public string MyProperty
{
get { return (string)GetValue(MyProperty); }
set { SetValue(MyProperty, value); }
}
public static readonly DependencyProperty MyPropertyProperty = DependencyProperty.Register("MyProperty", typeof(string), typeof(MyControl), null);
What new interesting functions could I obtain if I would use DependencyProperties instead of simple private fields?
I know that this question could seem already answered here on StackOverflow, but this particular case may be interesting to delve into, even with some example.
Thanks.
EDIT: I know there already are some answers to this topic, but they're mostly outdated, because now we have the UWP platform, which features "x:Bind" compile binding and many other things have been added to C#. I would like to know if something has changed since then.