开发者

How can I set an image for my BackgroundImage in my WPF Form?

开发者 https://www.devze.com 2022-12-14 13:07 出处:网络
In Windows Forms, I would go BackgroundImage and just select it from the comboBox. But here there is no such property.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消