[英]How can I show data in DataGrid when I press button in WPF Mvvm?
[英]How can I show data in a DataGrid in WPF?
我有一個enum和一個Foo類:
public enum Type
{
Arithmetic, Fraction, ...
}
public class Foo
{
public Foo(Type problemType, bool isCorrect)
{
ProblemType = problemType;
IsCorrect = isCorrect;
}
public Type ProblemType
{
get; set;
}
public bool IsCorrect
{
get; set;
}
}
然后我有一個Foo列表,按類型分類:
public void ShowGradesInDataGrid()
{
List<Foo> list = new List<Foo>();
list.Add(new Foo(Type.Arithmetic, true));
list.Add(new Foo(Type.Fraction, true));
list.Add(new Foo(Type.Arithmetic, false));
list.Add(new Foo(Type.Arithmetic, true));
list.Add(new Foo(Type.Fraction, false));
list.Add(new Foo(Type.Arithmetic, false));
List<List<Foo>> groupedLists = list.GroupBy(foo => foo.ProblemType)
.OrderBy(group => group.Key)
.Select(group => group.ToList())
.ToList();
}
我不知道如何在WPF中的數據網格中顯示grupedLists。 我試圖以這種方式顯示列表:
我把綠色和紅色放在哪里是填充的矩形。
if (IsCorrect)
// put rectangle with fill green
else
// put rectangle with fill red
那么顏色對我來說是一個加分,我實際上想要顯示在datagrid中分類的列表。 提前致謝。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.