Question

In the following code I am using a different image ImageUrlHoverString when a user select an item in the ListBox.

It is a big image and I see a gap of few moments when loading the image. Do you know a easy way to preload this image so this glitch do not happen any longer?

           <Image x:Name="FloorImage"
                   Grid.Row="1"
                   Margin="0,0,0,0"
                   Height="70">
                <Image.Style>
                    <Style TargetType="{x:Type Image}">
                        <Setter Property="Source" Value="{Binding ImageUrlString}" />
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}, Path=IsSelected}" Value="True">
                                <Setter Property="Source" Value="{Binding ImageUrlHoverString}"/>
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Image.Style>
            </Image>
Was it helpful?

Solution

I found a possible easy to implement solution. Basically I created another image with visibility hidden loading the urls for ImageUrlHoverString

            <Image x:Name="FloorImagePreload"
                   Width="200"
                   Height="80"
                   Visibility="Hidden"
                   Grid.Row="1"
                   Margin="0,0,0,0">
                <Image.Style>
                    <Style TargetType="{x:Type Image}">
                        <Setter Property="Source" Value="{Binding ImageUrlHoverString}" />
                    </Style>
                </Image.Style>
            </Image>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top