首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为ImageBrush添加加载指示器

为ImageBrush添加加载指示器
EN

Stack Overflow用户
提问于 2011-10-18 09:24:48
回答 3查看 993关注 0票数 1

我在silverlight for windows phone中有以下代码:

代码语言:javascript
复制
 <Border CornerRadius="0" x:Name="brdTest" BorderBrush="Black" BorderThickness="4" Width="100" Height="60">
                                <Border.Background>
                                    <ImageBrush x:Name="backgroundImageBrush" Stretch="Fill">
                                        <ImageBrush.ImageSource>
                                            <BitmapImage x:Name="bmpBackground" UriSource="http://www.images.com/1.jpg">
                                            </BitmapImage>
                                        </ImageBrush.ImageSource>
                                    </ImageBrush>
                                </Border.Background>
                            </Border>

当图像(http://www.images.com/1.jpg)加载并在图像加载时,如何从silverlight工具包中添加加载活动指示器?

图像是否加载在后台线程中?还是他们阻止了主UI线程?(也就是说,我想在许多列表框项目的模板中使用此方法)

我尝试了这段代码并加载了一个大图片(70MP),当图像加载时,应用程序的主UI线程没有冻结

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2011-10-18 13:41:13

您可以使用ProgressOverlayPerformanceProgressBar。下面是一个使用ProgressOverlay的示例

代码语言:javascript
复制
<Grid>
    <Border CornerRadius="0" x:Name="brdTest" BorderBrush="Black" BorderThickness="4" Width="400" Height="360">
        <Border.Background>
            <ImageBrush x:Name="backgroundImageBrush" Stretch="Fill">
                <ImageBrush.ImageSource>
                    <BitmapImage x:Name="bmpBackground" 
                                 UriSource="http://www.bestmotherofthegroomspeeches.com/wp-content/themes/thesis/rotator/sample-4.jpg"
                                 ImageOpened="bmpBackground_ImageOpened">
                    </BitmapImage>
                </ImageBrush.ImageSource>
            </ImageBrush>
        </Border.Background>
    </Border>

    <Controls:ProgressOverlay 
        x:Name="overlay"
        Width="400" Height="360">
        <Controls:ProgressOverlay.Content>
            <StackPanel>
                <TextBlock HorizontalAlignment="Center">Loading Image</TextBlock>
                <toolkit:PerformanceProgressBar IsIndeterminate="True"/>
            </StackPanel>
        </Controls:ProgressOverlay.Content>
    </Controls:ProgressOverlay>
</Grid>

bmpBackground_ImageOpened事件处理程序中,添加隐藏OverlayProgressoverlay.Hide();

这种方法似乎比仅仅使用PerformanceProgressBar更好,因为它为用户提供了一个关于正在发生的事情的指示。

PS:OverlayProgress没有正常工作,直到我在它的“内容”中添加了一个PerformanceProgressBar,如代码所示。(试着移除它,看看它是否适合你)。

我希望这有帮助:)

票数 0
EN

Stack Overflow用户

发布于 2011-10-18 10:36:17

检查此链接。在这里,作者解释了进度指示符,并使用不同的线程使用Dispatcher.BeginInvoke,您可以切换进度栏的可见性,并显示图像。希望这能有所帮助。

票数 0
EN

Stack Overflow用户

发布于 2011-10-18 13:09:52

刚刚添加到BitmapImage : ImageOpened="bmpBackground_ImageOpened“中,这将调用一个方法,以便我可以删除一个子(工具包加载项)。

编辑

如何调用包含名为"bmpBackground_ImageOpened“的图像的列表框来删除子列表?实际上,我想调用这个spacific的父BitmapImage,这样我就可以删除一个子BitmapImage(加载图像)。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7805070

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档