我正在动态创建银色按钮
HistoryButtton = new Button();
HistoryButtton.Content = "History";
HistoryButtton.Height = GetPercentageValue(TotalHeight, 8);
HistoryButtton.Width = GetPercentageValue(TotalHeight, 15);
我试过这个解决方案
ImageBrush brush = new ImageBrush();
brush.ImageSource = new BitmapImage(new Uri(@"Images/history.png", UriKind.Relative));
HistoryButtton.Background = brush;
但它不起作用。我也试过这个解决方案
Uri uri = new Uri("/Images/history.png", UriKind.Relative);
BitmapImage imgSource = new BitmapImage(uri);
Image image = new Image();
image.Source = imgSource;
HistoryButtton.Content = image;
但是这个解决方案也不起作用。请帮助我。在此先感谢。