在 Expression Blend 中隐藏绑定属性
这是我在这里发表的第一篇文章,所以要温柔:)。我们有一个当前基于 Windows 窗体的 C# 解决方案,并且我们正在推进 WPF。我们的软件并不是 100% 适合将数据与视图分离的 MVVM 方式,但它几乎适合。换句话说,我们几乎有了一个视图模型。问题是“viewmodel”有一大堆属性等,我想在通过 Expression Blend 显示时从绑定中隐藏这些属性。如果我理解正确的话,Blend 只会反映在类上以显示可用的属性。问题是 - 如何隐藏这些属性以使其出现在列表中?
我完全理解,如果从头开始,这将在一个单独的班级中,我不会有任何问题。但是现在将所有这些移到另一个类中会破坏我们所有依赖于现有代码的客户代码。聚合在这里肯定更好,但它还不是一个开始,所以我希望有一些属性可以用来装饰我们的属性来隐藏。
如果这是一个基本问题或者我没有完全理解的话,我深表歉意!
This is my first ever post here so be gentle :). We have a C# solution that is currently based around Windows Forms and we are moving forward with WPF. Our software is not 100% suited to the MVVM way of separating data from view but it ALMOST there. In other words we almost have a view model. The problem is that 'viewmodel' has a whole bunch of properties etc that I would like to hide from the Bindings when displayed through Expression Blend. If I understand this correctly Blend will just reflect on the class to show available properties. The question is - how do I hide these properties for appearing in the list?
I totally understand that if starting from scratch this would be in a separate class and I would have no problems. But moving all this out into another class now would break all of our customers code that relies on the code the way it is. Aggregation is definitely better here but it's a non starter so I'm hoping there's some attribute out there that we can decorate our properties with to hide.
Apologies if this is a basic question or I have not made total sense!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
一种方法是将属性转换为文字 get/set 方法。它不会破坏您的代码,除非您将属性用于除需要它们为属性的绑定之外的其他用途,并且 Blend 仅监视属性 AFAIK。这是免费的 Code Rush Express 中提供的重构。其他重构工具也可能有它。
One way would be to convert your properties to literal get/set methods. It wont break your code unless you are using the properties for other things than binding that requires them to be properties, and Blend is only watching for properties AFAIK. This is a refactoring available in Code Rush Express which is free. Other refactoring tools may have it as well.