使用 wpf 使用最少的资源在屏幕上绘制缩放背景

发布于 2024-08-04 08:38:32 字数 177 浏览 5 评论 0原文

我想在多个窗口上绘制相同的背景,例如背景可以是同心圆、多色网格或任何组合的数学形状。这些背景可以从不同模块中的外部例程进行定制。当我指示外部例程更改背景时,所有窗口都会自动重绘。唯一的问题是每个窗口可以有不同的大小,而这些都是矢量图形,没有任何像素化,

实现这一点的最佳方法是什么。我对 WPF 比较陌生,非常感谢任何帮助。

I want to draw the same background on multiple windows for example the background could be concentric circles, a multi colored grid or any mathematical shapes combined. These backgrounds are customizable from an external routine which is in a different module. When i instruct the external routine to change the background all the windows automatically redraws itself. The only problem is each window can have a different size, and these are all vector drawings without any pixelation

What is the best way to achieve this. I am relatively new to WPF and any help will be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

忆悲凉 2024-08-11 08:38:32

我认为您可以创建自己的控件,该控件继承自 FrameworkElement 并重写 OnRender 方法:

protected override void OnRender(DrawingContext drawingContext)

使用 DrawingContext 您可以绘制任何您想要的东西:)

I think you can create your own control that inherits from FrameworkElement and override the OnRender method:

protected override void OnRender(DrawingContext drawingContext)

Using the drawingContext you can draw whatever you want :)

变身佩奇 2024-08-11 08:38:32

我确实查看了绘图上下文并使用委托提供绘图例程,但我无法弄清楚如何在无法访问正在绘制的控件的情况下调整绘图大小。

I did look at the drawing context and to supply the drawing routine using a delegate, but I couldn't figure out how to have the drawings resize without having access to the control that's being drawn on.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文