Home > database >  WPF DataGrid, How to binding class properties as row?
WPF DataGrid, How to binding class properties as row?

Time:04-21

Model type is:

// Model
public class MyClass
{
    int A1 { get; set; }
    int A2 { get; set; }
    int A3 { get; set; }
    double B1 { get; set; }
    double B2 { get; set; }
    double B3 { get; set; }
}

...

private MyClass myClass1;
// Binding Source in ViewModel
public MyClass MyClass1
{
    Get => myClass1;
    Set => SetProperty(ref myClass1, value);
}

I want to bind the properties of MyClass to each row. MyClass1 property instance changes frequently.

Name Value
A1 123
A2 456
A3 789
B1 0.0
B2 1.1
B3 2.2

In View, it will look like above, and Value Column is editable. Values edited in the View are updated directly via binding. How should I implement the View in this case? 3rd party libraries cannot be used.

CodePudding user response:

You could use a PropertyGrid for this. If your software is for non commercial use you could use the enter image description here

  • Related