windows phone7 开发中图片画刷的那些事

给特定图片或者控件设置背景图片的代码为:

ImageBursh imgb = new ImageBrush();

imgb.ImageSource = new BItmapImage(new Uri("/png/mine.png",UriKind.Relative));

yourControl.Background = imgb;

获取特定控件的背景画刷为哪个图片,代码如下:

object wantedNode = ContentPanel.FindName(yourcontrolname);

控件类型 wantedChild = wantedNode as 控件类型;

string imgsrc = ((System.Windows.Media.Imaging.BitmapImage)((ImageBrush)wantedChild.Background).ImageSource).UriSource.ToString();

if (imgsrc == "png/mouseon.png")

{

 return true;

}

posted on 2012-02-28 09:35  勿惹尘埃  阅读(186)  评论(0编辑  收藏  举报