日期:2014-05-18  浏览次数:20742 次

画刷遮住图片应该怎么办?
程序中这样写
Rectangle recttangle = new Rectangle() {
  Width = 50,  
  Height = 50,
  };
  recttangle.SetValue(Canvas.LeftProperty, xxxx);
  recttangle.SetValue(Canvas.TopProperty, xxxx));
  recttangle.Fill =new SolidColorBrush(Colors.Red);
  LayoutRoot.Children.Add(recttangle);
。。。。。。。。
。。。。。。。
image.SetValue(Canvas.LeftProperty, xxxx);
image.SetValue(Canvas.TopProperty,xxxx);
image.Width = xxxx;
image.Height =xxxx;
结果没有出图片遮盖画刷的期望,反而是画刷遮住图片了,请问应该怎么解决啊?

------解决方案--------------------
分为2层,下面的层直接fill,上面的放图片
------解决方案--------------------
设置image的Canvas.ZIndex属性,让它高于rectangle的ZIndex,比如99
------解决方案--------------------
你的LayoutRoot.Children.Add(image)这个语句在哪里,这句决定他渲染的次序