Silverlight:删除模板部分

发布于 2024-07-27 15:57:20 字数 193 浏览 4 评论 0原文

我有一个关于模板零件的问题。 我想创建一个继承自 ChildWindow 的控件,但我不希望它有边框、确定/关闭按钮等。

删除我不想要的模板部分是可以接受的做法吗? 我已经在 Blend 中创建了 ChildWindow 模板的副本,并删除了模板部分,它工作正常 - 我只是想确保这不会在以后造成任何问题。

谢谢, 查尔斯

I have a question regarding template parts. I want to create a control that inherits from ChildWindow, but I don't want it to have a border, OK/Close buttons, etc.

Is it an acceptable practice to remove the template parts that I don't want? I have created a copy of the ChildWindow template in Blend and removed the template parts, and it works fine - I just want to make sure that that won't cause any problems down the road.

Thanks,
Charles

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

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

发布评论

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

评论(1

罗罗贝儿 2024-08-03 15:57:20

如果您阅读了 MSDN 上的一些自定义控件开发文档,其中特别提到开发人员应该预见到模板部分可能不存在并为其编写代码,所以我认为您没问题。 就我个人而言,当我需要删除模板部分时,我更喜欢将它们保留在 Xaml 中,但对于按钮之类的内容设置 Visibility = Collapsed,对于边框之类的内容设置 BorderWidth = 0。 我想是个人喜好。

If you read some of the custom control development documentation on MSDN it specifically mentions that developers should anticipate that template parts may not exist and code for it, so I think you're Ok there. Personally, when I need to remove template parts I prefer to leave them in the Xaml but set Visibility = Collapsed for something like a button or BorderWidth = 0 for something like a Border. Personal preference I suppose.

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