c# – WP7上ListPicker的caliburn.micro绑定约定
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了c# – WP7上ListPicker的caliburn.micro绑定约定,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1617字,纯文字阅读大概需要3分钟。
内容图文
![c# – WP7上ListPicker的caliburn.micro绑定约定](/upload/InfoBanner/zyjiaocheng/808/1d5a3887aa214a9c8ec210837847a1fb.jpg)
我正在为一个新项目尝试使用caliburn.micro框架,但我坚持使用绑定ListPicker(工具包中的那个).当我将控件更改为简单的DropDown时,一切都按预期工作.
我假设DropDown工作正常,因为默认约定为here:
AddElementConvention<Selector>(Selector.ItemsSourceProperty, "SelectedItem", "SelectionChanged")
.ApplyBinding = (viewModelType, path, property, element, convention) => {
if (!SetBinding(viewModelType, path, property, element, convention))
return false;
ConfigureSelectedItem(element, Selector.SelectedItemProperty,viewModelType, path);
ApplyItemTemplate((ItemsControl)element, property);
return true;
};
ListPicker没有实现Selector,所以我试图在我的引导程序中添加一个自定义约定:
static void AddCustomConventions() {
AddElementConvention<ListPicker>(ListPicker.ItemsSourceProperty, "SelectedItem", "SelectionChanged")
.ApplyBinding = (viewModelType, path, property, element, convention) => {
ConventionManager.ConfigureSelectedItem(element, ListPicker.SelectedItemProperty,viewModelType, path);
return true;
};
}
不幸的是,这不起作用.你能帮我吗?
解决方法:
我用这个约定解决了我的问题.
ConventionManager.AddElementConvention<ListPicker>(ListPicker.ItemsSourceProperty, "SelectedItem", "SelectionChanged")
.ApplyBinding = (viewModelType, path, property, element, convention) =>
{
if (ConventionManager.GetElementConvention(typeof(ItemsControl)).ApplyBinding(viewModelType, path, property, element, convention))
{
ConventionManager.ConfigureSelectedItem(element, ListPicker.SelectedItemProperty, viewModelType, path);
return true;
}
return false;
};
另外,还有另一个问题.我的SelectedItem属性返回null但我的Items属性不包含空值.我得到一个例外,所选项目无效,因为它不在列表中.
内容总结
以上是互联网集市为您收集整理的c# – WP7上ListPicker的caliburn.micro绑定约定全部内容,希望文章能够帮你解决c# – WP7上ListPicker的caliburn.micro绑定约定所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。