Hello,
Basically I have a WPF application that will display announcements to the user within a listbox. The information that populates the list box comes from a XML file which contains details about different announcements. I am then applying a data template to display the relevant pieces of information. What I have is two buttons at the bottom of the application, what I want is when the user clicks on the unread announcements button that the data is filtered to only show the unread announcements in the listbox. Then when the user clicks on All announcements I want them to all be shown again. The data template that I'm using will remain the same whichever button is clicked.
In the XML file which is being used there is a field called read, with 0 indicating it hasn't been read while 1 indicates that it has and this should be used to filter.
So really I'm just looking for examples of filtering or any good tutorials, so I can make some progress. If you require any of my code just let me know and I'll paste it in.
EDIT
Now added code below to show how the data is bound and also the layout of the data:
<XmlDataProvider
x:Key="Article"
Source="/Data/People.xml"
XPath="People/article"/>
<DataTemplate x:Key="AnnouncementTemplate">
<Border Background="#2200FF00"
BorderBrush="Black"
BorderThickness="1"
CornerRadius="8"
Margin="2,4,2,4"
Padding="2"
>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="30"/>
<ColumnDefinition Width="220"/>
</Grid.ColumnDefinitions>
<Border Background="#2200FF00"
BorderBrush="Black"
BorderThickness="1"
CornerRadius="8"
Margin="2,4,2,4"
Padding="2"
>
<StackPanel Grid.Column="0">
<Image Stretch="Fill" Width="20" Source="Images/BlueOrb.ico" Height="20" VerticalAlignment="Center" HorizontalAlignment="Center"/>
</StackPanel>
</Border>
<StackPanel Grid.Column="1" Margin="5">
<StackPanel Orientation="Horizontal">
<TextBlock FontWeight="Bold" Text="{Binding XPath=./author}" />
<TextBlock Text=" "/>
<TextBlock Text="{Binding XPath=./datetime}" TextTrimming="WordEllipsis"/>
</StackPanel>
<StackPanel>
<TextBlock FontWeight="Bold" Text="{Binding XPath=./title}"/>
</StackPanel>
<StackPanel>
<TextBlock Text="{Binding XPath=./body}" TextTrimming="WordEllipsis"/>
</StackPanel>
</StackPanel>
</Grid>
</Border>
</DataTemplate>
<ListBox Style="{StaticResource SpecialListStyle}"
Name="listBox1"
Margin="10,10,10,10"
Grid.Row="1"
ItemsSource="{Binding Source={StaticResource Article}}"
IsSynchronizedWithCurrentItem="True"
ItemContainerStyle="{StaticResource SpecialListItem}"
ItemTemplate="{StaticResource AnnouncementTemplate}"/>
Example of the data held in the XML file, the data wants to be filtered so it only shows messages where read == 0
<People>
<article>
<author>Michael</author>
<title>Happy Christmas</title>
<body>Merry Christmas one and all</body>
<priority>1</priority>
<uid>G-0617-8567-EF32-hello</uid>
<audience>0</audience>
<read>0</read>
<datetime>December 31, 2009 23:59:59</datetime>
</article>
<article>
<author>Gary</author>
<title>Landesk</title>
<body>Landesk Distributed</body>
<priority>0</priority>
<uid>G-0618-8567-EF32-hello</uid>
<audience>0</audience>
<read>1</read>
<datetime>December 31, 2009 23:59:59</datetime>
</article>
</People>