How can I set an image for my BackgroundImage in my WPF Form?
In Windows Forms, I would go BackgroundImage and just select it from the comboBox. But here there is no such property.
开发者_运维百科How would I go about this?
Use an ImageBrush for the Window.Background property:
<Window>
<Window.Background>
<ImageBrush ImageSource="..." />
</Window.Background>
</Window>
In general, when thinking about "how do I fill in an element or part of an element" (whether a window background, a text block foreground, or whatever) the answer will be a Brush, and WPF allows you to interchangeably use a solid brush, gradient brush, image brush, video brush or whatever. So you will be looking for the unified Background and Foreground properties rather than separate BackgroundColor, BackgroundGradient, BackgroundImage, BackgroundVideo etc. properties as you would have done in WinForms.
精彩评论