Smirti
Smirti

Reputation: 305

ReadOnly attribute in UWP

I couldn't find the ReadOnly attribute in UWP. I can set the ReadOnly attribute in WPF like below,

[ReadOnly(true)]
public double? Salary
{
    get
    {
        return _salary;
    }
    set
    {
        _salary = value;
        RaisePropertyChanged("Salary");
    }
}

Is ReadOnly attribute is not supported in UWP?

Upvotes: 4

Views: 408

Answers (2)

Clemens
Clemens

Reputation: 128042

You could make the setter private:

public double? Salary
{
    get { return _salary; }
    private set
    {
        _salary = value;
        RaisePropertyChanged("Salary");
    }
}

Upvotes: 12

Elvis Xia - MSFT
Elvis Xia - MSFT

Reputation: 10831

System.ComponentModel.ReadOnlyAttribute is not supported in UWP. UWP is targeting .NET Core while WPF targeting .NET Framework.

.NET for UWP apps does not include all the members of each type.

For all the types under namespace System.ComponentModel that are supported in .Net for UWP you can refer to System.ComponentModel namespaces for UWP apps.

From the Version Info section of ReadOnlyAttribute Documentation. It is also not available in Windows Universal Platform.

Upvotes: 5

Related Questions