SDL_SDL_SDL

I'm using ObjectDataProvider with IsAsynchronous="True"

When my app started user can see an empty list box for 10 seconds

How can I display something like "loading..." in that ListBox while it load its data asynchronously

I've tried to use DataTrigger and Bind it to ListBox.ItemContainerGenerator.Status but no luck

<Style TargetType="ListBox" x:Key="LazyListBox">

<Style.Triggers>

<DataTrigger

Binding="{Binding RelativeSource={xTongue Tiedtatic RelativeSource.Self}, Path=ItemContainerGenerator.Status}" Value="GeneratingContainers">

<Setter Property="Template">

<Setter.Value>

<ControlTemplate TargetType="{x:Type ListBox}">

<TextBlock>Loading...</TextBlock>

</ControlTemplate>

</Setter.Value>
</Setter>
</DataTrigger>

</Style.Triggers>

</Style>



Re: Windows Presentation Foundation (WPF) Asynchronous loading and template

Yi-Lun Luo - MSFT

Hello, you can simply put a TextBlock above the ListBox, and set its Visibility to Collapsed in the StatusChanged event of the ItemContainerGenerator.






Re: Windows Presentation Foundation (WPF) Asynchronous loading and template

SDL_SDL_SDL

Thanks for reply

Can I do it but put this TextBlock into my ListBox





Re: Windows Presentation Foundation (WPF) Asynchronous loading and template

Tamir Khason

Please see asynchronous binding patterns in this blog post. You do not have to display "Wait" teaser, but really load data and make it visible from the first item loaded

Hope it'll help






Re: Windows Presentation Foundation (WPF) Asynchronous loading and template

SDL_SDL_SDL

I've seen it already, thanks.

I can't load data one by one because it's just a one big database request that returns needed data once on startup.

So either have all the data or I have nothing.

And I have nothing for at least 10 seconds that's why I want to show something to a user.

I can solve this problem with a spash screen but there are other controls on the form and users sometimes don't need slowly loaded data.

So I want to show my form as soon as possible but warn a user that there is no error and his data is still loading.

Also if I close my application before all data loaded I've got ugly "RaceOnRCWCleanup was detected" message.