In XAML
I have below line in ItemControl
DataTemplate
. Source pic
is bind to Image from c#.But the loading of pic is taking some time.Till thenI want to display some default image and load other UI elements in that xaml file.
<Image Grid.Row="0" Source="{Binding pic}" Stretch="Fill" />
How to display default image till original pic is loaded from pic URL(url to server) and replace it with loaded image after done with pic loading from url?
Solution by Peter works, But the problem is my app hangs for around 10 seconds just before its displaying the image from server url. Code mentioned below
<ItemsControl x:Name="StoreCards" Margin="20"
HorizontalAlignment="Center" VerticalAlignment="Top"
Grid.Row="2" AlternationCount="100000" >
<ItemsControl.ItemTemplate>
<DataTemplate>
<Button BorderBrush="Black" Background="White" BorderThickness="0.2" Margin="10" Click="Card_Click">
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<Rectangle Fill="Red" Stretch="UniformToFill"/>
<Image x:Name="BannerImage" Stretch="UniformToFill">
<Image.Source>
<BitmapImage UriSource="{Binding pic, IsAsync="True"}"/>
</Image.Source>
</Image>
</Grid>
</Button>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<WrapPanel ItemHeight="200" ItemWidth="300"/>
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
Thanks