繁体   English   中英

将数据绑定到WP7中的Panorama Control的图像不起作用

[英]Data binding image to Panorama Control in WP7 not working

谁能阐明为什么以下代码不起作用? “不起作用”是指图像未在Panorama控件中呈现:

XAML

DataContext="{Binding RelativeSource={RelativeSource Self}}"
shell:SystemTray.IsVisible="False">

<Grid x:Name="LayoutRoot">
    <controls:Panorama Title="My Control">
        <controls:Panorama.Background>
            <ImageBrush ImageSource="{Binding RandomImage}"/>
        </controls:Panorama.Background>

C#

public string RandomImage { get; set; }

注意: RandomImage属性设置为Internet上的公共jpg图像。

编辑

我也尝试过将RandomImage属性更改为ImageSource,但是没有任何运气。

我要RandomImage猜想,您是在页面加载后的某个时候设置RandomImage ,这意味着绑定已被检查。 您需要实现INotifyPropertyChanged并在Setter中为RandomImage调用PropertyChanged事件。 有关此内容的详细说明,请查看此MSDN文章

它的长处和短处是在页面加载时检查绑定,然后除非有什么触发它,否则不会再次检查。 实现INotifyPropertyChanged意味着,当您调用PropertyChanged事件时,它将通知UI再次检查绑定并查看新内容,以便它可以自我更新。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM