c#WPF GridView列显示空项目

时间:2018-08-24 11:23:52

标签: c# wpf

我正在尝试制作一个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; 
    }

1 个答案:

答案 0 :(得分:0)

很难肯定地说不知道如何定义SetOverview类,但是如果它只是一个具有3个字符串成员(SetName,SetCode,SetCount)的类,请确保将它们定义为公共属性(带有get和set),而不仅仅是常规字符串。例如:

# Find the indices of all the word starts
word_starts = [0] + [m.start()+1 for m in re.finditer(' ', s)]

# Break the mapping list into an actual list
mapping = mapping_list.split(' ')

# Find the indices in the mapping list we care about
word_indices = [i for i, e in enumerate(mapping) if e == '1']

# Map those indices onto the word start indices
word_starts_at_indices = [word_starts[i] for i in word_indices]
# Or you can do the last line the fancy way:
# word_starts_at_indices = operator.itemgetter(*word_indices)(word_starts)