WP7 中的绑定 Panorama.SelectedIndexProperty
首先,SelectedIndex 没有在标记中公开,因此您必须在后面的代码中执行此操作,对吗?
其次,我在后面的代码中设置了绑定:
Binding binding = new Binding("Main.PanoSelectedIndex.ObservedObject");
binding.Mode = BindingMode.TwoWay;
rootPano.SetBinding(Panorama.SelectedIndexProperty, binding);`
(ObservedObject 实现 iNotifyChanged)
绑定路径指向我的主视图模型,我可以看到 PanoramaItem 正在更新绑定。但是,当其他内容(MVVM Light 命令)更改绑定时,全景图不会响应。有什么想法吗?
谢谢, 罗杰
First, SelectedIndex is not exposed in markup, so you have to do it in code behind, right?
Second, I have set the binding in code behind:
Binding binding = new Binding("Main.PanoSelectedIndex.ObservedObject");
binding.Mode = BindingMode.TwoWay;
rootPano.SetBinding(Panorama.SelectedIndexProperty, binding);`
(ObservedObject implements iNotifyChanged)
The binding path points to my Main view model, and I can see that the PanoramaItem is updating the binding. However,the panorama does not respond when something else (a MVVM Light command) changes the binding. Any ideas?
Thanks,
Roger
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
引用Windows Phone 开发人员常见问题解答
更新:您可以使用
DefaultItem
保存/恢复Panorama
的选择,如下所示(代码来自 Jeff Prosise 的 最近的博客文章) :To quote from the Windows Phone Developer FAQ
UPDATE: You can use the
DefaultItem
to save/restore the selection for aPanorama
as shown below (code from Jeff Prosise's recent blog post):据我所知 SelectedIndex 是 Panorama 中的只读属性(奇怪为什么 WP7 SDK 将其设为只读)。因此,您只能将 UI 更改返回到 VM,并且无法通过 VM propertychange 更新 UI。
DefaultItem 是用于以编程方式设置索引的属性。
同样,以编程方式设置已实例化的全景的问题是,标题和全景项目的对齐不会同步。无论如何,我并不劝阻,但仍然有一些被黑客攻击的机会。
As far as I know SelectedIndex is a readonly property in Panorama ( Weired why WP7 SDK made it readonly). So you will get only UI change back to your VM, and you cant update UI through the VM propertychange.
And DefaultItem is the property which used to set the index programatically.
Again the issue of programatically setting an already instantiated Panorama is that, the alignment of the Title and Panoramaitem wont be in sync. Anyway I am not discouraging but there is still some chance of hack there.