В моем приложении C#/WPF у меня есть
Код: Выделить всё
ListViewКод: Выделить всё
GridViewКод: Выделить всё
Код: Выделить всё
ObservableCollectionКод: Выделить всё
ConditionКод: Выделить всё
public class Condition
{
public string Name { get; set; }
public ObservableCollection Properties { get; set; }
public class Property
{
public string Name { get; set; }
public double Value { get; set; }
}
}
Код: Выделить всё
INotifyPropertyChangedIdea is that GridView Column headers should display
Код: Выделить всё
NameКод: Выделить всё
ConditionКод: Выделить всё
NameКод: Выделить всё
ValueКод: Выделить всё
ConditionКод: Выделить всё
private ObservableCollection CreateConditions()
{
ObservableCollection conditions = new();
conditions.Add(
new Condition()
{
Name = "c1",
Properties = new()
{
new() { Name = "p1", Value = 5 },
new() { Name = "p2", Value = 10 },
new() { Name = "p3", Value = 15 },
}
});
conditions.Add(
new Condition()
{
Name = "c2",
Properties = new()
{
new() { Name = "p1", Value = 8 },
new() { Name = "p2", Value = 12 },
new() { Name = "p3", Value = 20 },
}
});
conditions.Add(
new Condition()
{
Name = "c3",
Properties = new()
{
new() { Name = "p1", Value = 11 },
new() { Name = "p2", Value = 17 },
new() { Name = "p3", Value = 25 },
}
});
return conditions;
}
Код: Выделить всё
- c1 c2 c3
p1 5 8 11
p2 10 12 17
p3 15 20 25
Код: Выделить всё
public class TableResultsViewViewModel
{
public ObservableCollection Conditions { get; set; }
public TableResultsViewViewModel(ObservableCollection conditions)
{
this.Conditions = conditions;
}
}
Код: Выделить всё
public partial class MainWindow : Window
{
private TableResultsViewViewModel vm;
public MainWindow()
{
InitializeComponent();
ObservableCollection conditions = CreateConditions(); //sample data creation method from before
vm = new TableResultsViewViewModel(conditions);
this.DataContext = vm;
}
}
Код: Выделить всё
ObservableCollection ConditionsКод: Выделить всё
ConditionКод: Выделить всё
PropertyКод: Выделить всё
PropertiesКод: Выделить всё
ConditionИсточник: https://stackoverflow.com/questions/781 ... collection
Мобильная версия