同时还有一个UserControl用来承载图片代码如下:
<Canvas x:Name="LayoutRoot" Background="White">
<Image x:Name="photo" Width="320" Height="240" Stretch="UniformToFill" Margin="10" />
</Canvas>
C#:
public partial class UC_pic : UserControl
{
public UC_pic()
{
InitializeComponent();
}
private string _imgUrl;
public string ImageUrl
{
get { return this._imgUrl; }
set {
//设置图片资源属性
this._imgUrl = value;
Uri uri = new Uri(value, UriKind.Relative);
BitmapImage bitimg = new BitmapImage(uri);
this.photo.Source = bitimg;
}
}
}
这样就完成了跑马灯的效果,如图:
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持ASPKU。
注:相关教程知识阅读请移步到c#教程频道。











