如何在 WPF 表单中设置背景图像的图像?
在 Windows 窗体中,我会转到“BackgroundImage”并从组合框中选择它。但这里没有这样的财产。
我该怎么办呢?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 ImageBrush 作为 Window.Background 属性:
一般来说,当考虑“如何填充元素或元素的一部分”(无论是窗口背景、文本块前景还是其他)时,答案将是 Brush ,WPF 允许您互换使用实心画笔、渐变画笔、图像画笔、视频画笔或其他画笔。因此,您将寻找统一的Background 和Foreground 属性,而不是像在WinForms 中那样单独的BackgroundColor、BackgroundGradient、BackgroundImage、BackgroundVideo 等属性。
Use an ImageBrush for the Window.Background property:
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.