wpf中常常需要给控件添加背景图片,下边以wrapPanel为例,使用代码添加背景图片

         WrapPanel xwraPanel = new WrapPanel();

            ImageBrush ximgBrush = new ImageBrush();

           Uri xuri = new Uri("pack://application:,,,/Images/JXimgs/MeterLayout.png", UriKind.Absolute); //注意这个的写法      

     ximgBrush.ImageSource = new BitmapImage(xuri);        

     xwraPanel.Background = ximgBrush;

 

另外我们在项目中可以设置控件的BackGround=“Transparent” 使本控件透明,而显示父容器的背景色

相关文章:

  • 2021-12-31
  • 2022-12-23
  • 2021-04-08
  • 2021-10-28
  • 2022-01-18
  • 2021-12-14
  • 2021-10-18
  • 2022-12-23
猜你喜欢
  • 2021-07-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-20
  • 2021-12-18
相关资源
相似解决方案