开发者

OnScreen event in wpf

I have a small custom control which downloads & displays a contacts image. It ensures that only 1 image is being downloaded at a time by adding itself to a static queue of images awaiting to be downloaded.

It is possible to get quite long contact lists. So I want 开发者_Python百科it to only enter the download queue when it actually becomes visible on the screen (there's a default image).

I've tried placing the logic in the Loaded event, overriding OnRender and the IsVisibleChanged event, but none seem to give me what I want.

any suggestions?

D.R

Edit: This is a WPF Application, sorry for not mentioning before...


Some system controls (like ListView) have property "VirtualMode" if you set it to true and handle RetrieveVirtualItem event. This event invokes for items which are visible currently and you have to fill those items with data(images) you want. So that you don't need to fill all items at once.


Have you considered using a PriorityBinding in order to provide that functionality?

<DataTemplate DataType="{x:Type vm:MyViewModel}">
    <StackPanel Orientation="Horizontal">
        <Image>
            <Image.Source>
                <PriorityBinding FallbackValue="{StaticResource ImgDownloading}">
                    <Binding Path="ImageSource" IsAsync="True" />
                </PriorityBinding>
            </Image.Source>
        </Image>
        <Label Content="{Binding Name}" />
    </StackPanel>
</DataTemplate>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜