【WPF】Button按钮动态设置Background背景颜色

如果想给按钮背景设置为一张图片:

Button btn = new Button();
ImageBrush brush = new ImageBrush();
brush.ImageSource = new BitmapImage(new Uri("Images/test.png", UriKind.Relative));
btn.Background = brush;
Background = System.Windows.Media.Brushes.White,

  

posted @ 2022-07-29 12:17  多见多闻  阅读(1571)  评论(0)    收藏  举报