如何从 c Sharp 文件在 WPF 画布上显示矩形
我知道如何在 WPF xaml 中创建一个矩形,然后在 c Sharp 文件中编辑它。我感兴趣的是在 c Sharp 文件中创建矩形,将其显示在 WPF 画布上,然后能够对其进行操作。我和我的朋友正在开发一款游戏,我们希望能够从源代码动态生成新对象。任何帮助都会很棒:)
I know how to create a rectangle in the WPF xaml, then edit it in the c sharp file. What I'm interested in is creating the rectangle in the c sharp file, displaying it on the WPF canvas, then being able to manipulate it. My friends and I are working on a game, and we'd like to be able to generate new objects from the source code on the fly. Any help would be great :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这很容易。假设您有一个像此 XAML 中那样的 Canvas,
您可以使用如下代码:
It's easy. Provided that you have a Canvas like in this XAML
you can play around with code like this: