tags:

views:

872

answers:

4

So I have a little WPF XAML that gets the titles of my RSS feed and puts them in a ListBox.

However, it takes about 2 seconds to load.

How can I have put some kind of AJAXy spinning graphic in the ListBox until the data is there?

Here is the code:

<Window x:Class="WpfApplication5.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">
    <StackPanel>
        <StackPanel.Resources>
            <XmlDataProvider x:Key="ExternalColors" Source="http://www.tanguay.info/web/rss" XPath="/"/>
        </StackPanel.Resources>
        <TextBlock Text="RSS Feeds:"/>
        <ListBox Name="lbColor" Height="200" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding Source={StaticResource ExternalColors}, XPath=//item/title}"/>

        <TextBlock Text="You selected this feed:"/>
        <TextBox
            Text="{Binding ElementName=lbColor, Path=SelectedValue}"
            Background="{Binding ElementName=lbColor, Path=SelectedValue}">
        </TextBox>
    </StackPanel>
</Window>
+1  A: 

You could could create the spinny-loady-thingy and add it to the AdornerLayer of the ListBox.

Micah
+1  A: 

Hi there,

The following videos are from mix08 and walk you through doing exactly what you want.

Part 1

Part 2

(watch in succession if possible. it is in silverlight but will point you in the right direction.)

Have Fun.

Blounty
A: 

You could exploit the IsAsynchronous property of the XmlDataProvider together with the DataChanged event (I didn't try): have a look at the documentation. ;-)

Fabrizio C.
+4  A: 
David Schmitt