使用 MVVM 绑定各种全景/透视项目
有人可以帮助我设计/理解这个问题吗:我需要实现的是带有全景/枢轴控件的页面,其中其项目(全景/枢轴)将使用标准 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您在全景/透视图上有动态页数,您可以使用选择器根据您的内容选择合适的模板。
实现 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
您可以向要用作数据模板的用户控件添加依赖项属性,例如名为“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.