在 Expression Blend 中隐藏绑定属性

发布于 2024-10-03 02:39:23 字数 408 浏览 7 评论 0原文

这是我在这里发表的第一篇文章,所以要温柔:)。我们有一个当前基于 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 技术交流群。

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

发布评论

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

评论(1

余厌 2024-10-10 02:39:23

一种方法是将属性转换为文字 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.

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