Silverlight:删除模板部分
我有一个关于模板零件的问题。 我想创建一个继承自 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您阅读了 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.