[英]c# WPF GridView Columns Showing Empty Items
我正在嘗試制作一個 WPF 程序,該程序將遍歷項目列表並將每個列出的項目放入列表視圖中。
但是,當我將項目添加到列表視圖時,列只顯示為空(但當我將鼠標懸停在列表視圖上時突出顯示,以便添加項目)
我只是想知道為什么這些值沒有顯示在列中。 此外,如果它有助於我知道“SetData”中有值,因為我做了一個步驟並觀察了添加的值。
XAML
<ScrollViewer Grid.Column="1" Grid.Row="1" Grid.ColumnSpan="4">
<ListView x:Name="LIV_SetList">
<ListView.View>
<GridView>
<!--Each column will display a specific property of the set, its name, code and total number of cards-->
<GridViewColumn Header="Set Name" DisplayMemberBinding="{Binding SetName}"/>
<GridViewColumn Header="Set Code" DisplayMemberBinding="{Binding SetCode}"/>
<GridViewColumn Header="Number Of Cards" DisplayMemberBinding="{Binding SetCount}"/>
</GridView>
</ListView.View>
</ListView>
</ScrollViewer>
。CS
// Shove all the data just gathered into a Set Overview, and put that set overview into a list item which is then added to the listview
Classes.SetOverview SetData = new Classes.SetOverview { SetName = SetReader["name"].ToString(), SetCode = TempCode, SetCount = SetSize };
LIV_SetList.Items.Add(SetData);
SetOverview 類
public class SetOverview
{
//This Is Used On The Main Window To Display Information Regarding A Given Sets Name Code And Number Of Cards
public string SetName;
public string SetCode;
public int SetCount;
}
在不知道如何定義 SetOverview 類的情況下很難確定,但如果它只是一個具有 3 個字符串成員(SetName、SetCode、SetCount)的類,請確保將它們定義為公共屬性(使用 get 和 set)而不僅僅是常規字符串。 例如:
public class SetOverview
{
public string SetName { get; set; }
public string SetCode { get; set; }
public string SetCount { get; set; }
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.