我想在WPF中的圖像控件上有一個背景圖像,例如,如果我加載透明的PNG,我仍然能夠看到背景。是否有可能,或者微軟完全放棄了WPF的這個特性,我必須依賴StackPanels/Grids /無論如何實現這一點?在WPF圖像控件上設置背景圖片?
5
A
回答
13
Image
沒有財產,以便對,只是把一個Border
的Image
並設置Border.Background
到ImageBrush
。
4
不,你需要圖像。將窗口背景設置爲圖像並將根元素背景設置爲圖像
<Window.Background>
<ImageBrush ImageSource="BackgroundImage.png"/>
</Window.Background>
<Grid.Background>
<ImageBrush ImageSource="ForegroundImage.png"/>
</Grid.Background>
2
如此處所測試的代碼所示,將窗口背景設置爲圖像畫筆。通知AllowsTransparency =「True」 And WindowStyle =「None」刪除邊框。
<Window x:Class="khaosInstallerWPF.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="616" Width="773"
ResizeMode="NoResize" Icon="images/khaos_Installer_UI.png"
AllowsTransparency="True" WindowStyle="None">
<Window.Background>
<ImageBrush ImageSource="images\khaos_Installer_UI.png"/>
</Window.Background>
<Grid Margin="0,0,0,0"></Grid>
</Window>
獎勵:如果你使用的是形狀適合務必使你的表單拖拽
namespace khaosInstallerWPF
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
MouseDown += delegate { DragMove(); };
}
}
}
相關問題
- 1. 背景圖片上的背景圖像
- 2. MFC - 在控件上設置背景圖片
- 3. 在GADBannerView上設置背景圖片
- 4. 使用樣式設置WPF控件背景圖像?
- 5. 控件背景色(設置背景圖片)
- 6. 設置背景或背景圖片
- 7. 在LinearLayout上設置背景圖像
- 8. J2ME在背景圖像上設置textfield
- 9. QDialog - 設置背景圖片
- 10. 設置背景圖片NSToolbar
- 11. 設置背景圖片
- 12. 設置背景圖片
- 13. Dropzone.js設置背景圖片
- 14. 設置Emacs背景圖片
- 15. 設置圖片爲背景
- 16. 設置iOS背景圖片
- 17. 設置背景圖片
- 18. 設置背景圖片
- 19. UINavigationBar - 設置背景圖片?
- 20. 如何在背景圖片上放置背景圖片?
- 21. 從控制器設置背景圖像
- 22. 設置背景圖像控制
- 23. 使用C在WPF中的網格上設置背景圖像#
- 24. 設置JWindow背景圖像
- 25. 設置背景圖像alertdialog
- 26. angularjs設置背景圖像
- 27. 設置UIScrollView背景圖像
- 28. UITableViewCell背景圖像設置
- 29. 從Android上的圖像設置背景
- 30. 背景圖片上的圖像
的確。有點煩人,但它有訣竅。謝謝 ! – pikzen