繁体   English   中英

c# WPF GridView 列显示空项目

[英]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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM