首页 > TAG信息列表 > ImageBrush

【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,