Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 与列表项绑定的可见性_C#_Windows Phone 8_Binding_Listbox_Visibility - Fatal编程技术网

C# 与列表项绑定的可见性

C# 与列表项绑定的可见性,c#,windows-phone-8,binding,listbox,visibility,C#,Windows Phone 8,Binding,Listbox,Visibility,我只想显示CountAnswers大于0的项目。 我有100个项目,但只有少数有CountAnswers>0。然后使用LINQ <ListBox Name="QuestionList" ItemsSource="{Binding Reports}"> <ListBox.ItemTemplate> <DataTemplate > <TextBlock Text="{Binding C

我只想显示CountAnswers大于0的项目。 我有100个项目,但只有少数有
CountAnswers
>0。

然后使用LINQ

<ListBox Name="QuestionList" ItemsSource="{Binding Reports}">
    <ListBox.ItemTemplate>
        <DataTemplate >            
             <TextBlock Text="{Binding CountAnswers}"/>                      
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>
public IEnumerable报表服务器
{
得到
{
返回报告。其中(x=>x.CountAnswers>0);
}
}

如果我想同时显示DateTimeStartTimeWrap文本块到stackpanel中,添加下一个文本块,并将其与countsanswers属性绑定,该怎么办
<ListBox Name="QuestionList" ItemsSource="{Binding Reports}">
    <ListBox.ItemTemplate>
        <DataTemplate >            
             <TextBlock Text="{Binding CountAnswers}"/>                      
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>
public IEnumerable<MyItem> ReportsWithAnwers
{
    get
    {
       return Reports.Where(x => x.CountAnswers > 0);
    }
}

<ListBox Name="QuestionList" ItemsSource="{Binding ReportsWithAnwers}">
    <ListBox.ItemTemplate>
        <DataTemplate >            
             <TextBlock Text="{Binding CountAnswers}"/>                      
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>