我需要給背景圖片的大小,因爲我將圖片圖片(32x32)作爲背景圖片添加到我的按鈕中,對於按鈕來說很大,而且看起來很糟糕,所以XAML代碼是這樣的:有什麼辦法來操縱WPF中按鈕的背景圖片嗎?
<Window x:Class="apple.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow">
<Grid>
<Image Source="C:\Users\Fernando\Desktop\Eye-Mouse\apple\apple\img0.jpg" Stretch="Fill"/>
<UniformGrid Name="gridx" Rows="6">
</UniformGrid>
</Grid>
</Window>
而到了uniformGrid我添加的按鈕,像這樣:
ImageBrush ib = new ImageBrush();
System.Windows.Controls.Button newBtn = new Button();
FileToImageIconConverter some = new FileToImageIconConverter(link[n]);
ImageSource imgSource = some.Icon;
ib.ImageSource = imgSource;
newBtn.Background = ib;
gridx.Children.Add(newBtn);
感謝您的任何幫助。
你能澄清一下「看起來不好」是什麼意思嗎?另外,您是否可以爲您的問題添加修剪後的屏幕截圖,並且更準確地說明您希望它看起來像什麼樣子? – 2012-01-09 09:17:22