开发者

Show only allowed data in WPF Listbox Databinding

I currently have a list box:

<ListBox HorizontalAlignment="Left"
         ItemsSource="{Binding Data, ElementName=bookingDomainDataSource}"
         Margin="158,134,0,45"
         x:Name="bookingListBox"
         Width="429"
         SelectedItem="{Binding Path=开发者_如何学CSelectedItem, Mode=TwoWay, ElementName=bookingComboBox}">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Path=userId}"
                           Width="100" />
                <TextBlock Text="{Binding Path=bookingName}"
                           Width="100" />
                <TextBlock Text="{Binding Path=bookingDate}"
                           Width="100" />
                <TextBlock Text="{Binding Path=showId}"
                           Width="100" />
                <TextBlock Text="{Binding Path=paymentId}"
                           Width="100" />
                <TextBlock Text="{Binding Path=ticketId}"
                           Width="100" />
                <TextBlock Text="{Binding Path=ticketQuantity}"
                           Width="100" />
            </StackPanel>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

And I would like to only show rows from the itemssource that have a certain userId, how can I do this?

Thanks.


I think the best solution to this would be to filter the data source BEFORE you get to the front end.


You want to define a filter for your listview.

Uodate: sorry missed the silverlight tag. However CollectionViewSource should still be useful to you. Here a sample using the CollectionViewSource in Silverlight.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜