How can we improve Windows Developer?

Modify the language to allow for observable properties rather than requiring explicit INPC

Something more like:

public observable int Foo { get; set; }

Rather than having to do all the manual event raising required by INotifyPropertyChanged

153 votes
Sign in
Sign in with: facebook google
Signed in as (Sign out)

We’ll send you updates on this idea

Pete Brown shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →


Sign in
Sign in with: facebook google
Signed in as (Sign out)
  • 鵜野建次 commented  ·   ·  Flag as inappropriate

    WPF native observable support will be great!

    Alternatively, ReactiveProperty based on Reactive Extension is available.

    public class Model {
    public ReactiveProperty<string> Address;

    <TextBlock Text="{Binding Address.Value}" />

    Note: We need to have suffix `.Value`.

    While, Android has a Data Binding Library (including Observable binding) since Android 2.1.

    private static class User {
    public final ObservableField<String> firstName = new ObservableField<>();
    public final ObservableField<String> lastName = new ObservableField<>();
    public final ObservableInt age = new ObservableInt();

    // In Java code:
    // user.firstName.set("Google");
    // int age = user.age.get();

    // In layout xml:
    // <TextView
    // android:text="@{user.lastName}"
    // android:layout_width="wrap_content"
    // android:layout_height="wrap_content"/>

    Also Two-way data binding: text="@={user.lastName}"

  • Steven R. commented  ·   ·  Flag as inappropriate

    It would be nice if C# properties were first-class objects. Their "property container" objects by default might just be a pass-through getter and setter, but other implementations such as one with an INPC side effect or a vetoable setter could be swapped in. Without first-class properties, you just have boilerplate and Java Beans-style handling conventions to work with them.

  • Lewis Westbury commented  ·   ·  Flag as inappropriate

    This would be extraordinarily helpful to remove a large amount of boilerplate code across just about every project I've worked on.

  • Anonymous commented  ·   ·  Flag as inappropriate

    This request is duplicated higher up in the list (is there any way to merge suggestions?)

  • Mendel Monteiro-Beckerman commented  ·   ·  Flag as inappropriate

    It would be great if the properties were actually of type IObservables of T as this would make the composition of properties much more declarative. This would require changes to the binding mechanism in WPF and the designer. In the designer it and in converters we would want the type to be T whereas in the ViewModel we would want it to be IObservable of T.

  • Jeremy Wilkins commented  ·   ·  Flag as inappropriate

    This design is automated by tools like Resharper, but I agree that making it part of the language makes more sense to promote the MVVM pattern.

    In addition, unit testing the properties wouldn't be necessary except to verify that it is marked observable.

    This would be easy to add, since the observable pattern is well-known.

Feedback and Knowledge Base