4
我正在嘗試caliburn.micro框架爲一個新的項目,但我堅持綁定一個ListPicker(從工具包)。當我將控件更改爲簡單的DropDown時,一切都按預期工作。 我認爲下拉工作,因爲默認慣例的正確,實現here:針對WP7上的ListPicker caliburn.micro綁定約定
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沒有實現選擇,所以我想在我的引導程序添加自定義的約定:
static void AddCustomConventions() {
AddElementConvention<ListPicker>(ListPicker.ItemsSourceProperty, "SelectedItem", "SelectionChanged")
.ApplyBinding = (viewModelType, path, property, element, convention) => {
ConventionManager.ConfigureSelectedItem(element, ListPicker.SelectedItemProperty,viewModelType, path);
return true;
};
}
不幸的是,這並不奏效。你能幫我嗎?