使用 MVVM 绑定各种全景/透视项目

发布于 2024-12-25 19:20:02 字数 343 浏览 4 评论 0原文

有人可以帮助我设计/理解这个问题吗:我需要实现的是带有全景/枢轴控件的页面,其中其项目(全景/枢轴)将使用标准 MVVM 模式通过绑定设置。问题是我需要在每个全景/枢轴上有不同的内容(不同的用户控件),这意味着如果我定义一个全景/枢轴项模板,我注定所有它们都是相似的,这不是我想要的。

我发现这里已经问过这个问题:Databound windows Phone panorama with MVVM design 但我仍然不清楚。非常感谢。

could someone help me with design/understanding the problem: what I need to achieve is page with Panorama/Pivot control, where its items (panos/pivots) will be set via binding, using standard MVVM pattern. Problem is I need to have different content (different user controls) on each pano/pivot, that means If I define a panorama/pivot item template, I doom all of them to be alike, which is not what I want.

I found this question here already asked: Databound windows phone panorama with MVVM design but its still not clear to me. Many thanks.

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

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

发布评论

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

评论(2

蛮可爱 2025-01-01 19:20:02

如果您在全景/透视图上有动态页数,您可以使用选择器根据您的内容选择合适的模板。

实现 DataTemplateSelector

另外,Data Binding Pivot to MVVM 也可能对您有帮助

If you have a dynamic page count on panorama/pivot you could use selector to choose what template is right according to your content.

Implementing DataTemplateSelector

Also, Data Binding Pivot to MVVM may help you too

只是在用心讲痛 2025-01-01 19:20:02

您可以向要用作数据模板的用户控件添加依赖项属性,例如名为“Type”的依赖项属性,并且根据该属性,您可以更改用户控件(数据模板)的布局 - 例如您的用户控件内可以有多个网格,并且可以根据类型显示和隐藏它们。

You could add a dependency property to the user control that you want to use as a data template, a dependency property named "Type" for example and depending on that property you can change the layout of your user control (data template) - for example you could have multiple grids inside your user control and you could show and hide them depending on the type.

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