32
A
回答
30
你忘了Background屬性。畫筆應該是一個ImageBrush,其ImageSource可以設置爲圖像路徑。
<Grid>
<Grid.Background>
<ImageBrush ImageSource="/path/to/image.png" Stretch="UniformToFill"/>
</Grid.Background>
<...>
</Grid>
19
我有我的圖像在一個單獨的類庫(「MyClassLibrary」),他們被放置在文件夾「圖像」。在這個例子中,我使用「myImage.jpg」作爲背景圖片。
ImageBrush myBrush = new ImageBrush();
Image image = new Image();
image.Source = new BitmapImage(
new Uri(
"pack://application:,,,/MyClassLibrary;component/Images/myImage.jpg"));
myBrush.ImageSource = image.Source;
Grid grid = new Grid();
grid.Background = myBrush;
+0
自從你創建'Image'沒有意義'不要用它來做任何事情。你可以直接在'ImageBrush'上設置'ImageSource'。 – devios1 2016-11-25 18:13:45
62
所有這一切都可以很容易地在XAML由網格
<Grid>
<Grid.Background>
<ImageBrush ImageSource="/MyProject;component/Images/bg.png"/>
</Grid.Background>
</Grid>
留給你做的,是添加一個文件夾來解決所謂的「形象」,並加入以下代碼來達到的將現有文件添加到新的'Images'文件夾中,在這種情況下稱爲'bg.png'
0
爲了避免路徑問題,您可以簡單地嘗試此操作,只需在圖像文件夾中保留背景圖像並添加此代碼
<Grid>
<Grid.Background>
<ImageBrush Stretch="Fill" ImageSource="..\Images\background.jpg"
AlignmentY="Top" AlignmentX="Center"/>
</Grid.Background>
</Grid>
相關問題
- 1. 在WPF圖像控件上設置背景圖片?
- 2. 使用ImageBrush的網格背景圖像
- 3. 如何在wpf中設置網格列的背景顏色?
- 4. 在LinearLayout上設置背景圖像
- 5. J2ME在背景圖像上設置textfield
- 6. 爲iOS設置網站背景圖像
- 7. 從Android上的圖像設置背景
- 8. 在WPF中設置我的圖像背景
- 9. 在WPF頁面中添加網格背景圖像
- 10. 使用BrowserAction設置背景圖像
- 11. 使用Jekyll-Assets設置背景圖像
- 12. 使用樣式設置WPF控件背景圖像?
- 13. 設置背景顏色和設置圖像在ImageButton背景 - Android
- 14. 在WPF上設置背景顏色ContentView
- 15. WPF使用網格作爲背景
- 16. 如何在wpf中設置動態窗口背景圖像
- 17. 在UIViewController(MonoTouch)中設置背景圖像
- 18. 在SD卡中設置背景圖像
- 19. 在Java中設置背景圖像
- 20. 在swift中設置navigationBar背景圖像
- 21. 設置JWindow背景圖像
- 22. 設置背景圖像alertdialog
- 23. angularjs設置背景圖像
- 24. 設置UIScrollView背景圖像
- 25. UITableViewCell背景圖像設置
- 26. 在網格視圖中按項目位置設置背景
- 27. 如何在C#WPF代碼中更改\設置按鈕的背景圖像?
- 28. 在背景圖像上設置圖像的問題android
- 29. 使用Swing在JFrame上設置背景圖像
- 30. 如何使用Interface Builder在視圖中設置背景圖像
可以告訴我這個 – Shashank 2010-06-23 10:41:56
的確切語法@SHASHANK:語法是這樣的:' ' –
Amsakanna
2010-06-23 10:49:19