您必須添加自定義約定才能綁定到基於x:Name
的該控件。沒有辦法解決這個問題,因爲它是第三方控件,否則你將不得不使用屬性。只有那些開箱即用的控件是那些包含在wpf/silver/windows phone framework for .NET中的控件。 。如果內存爲我服務,那麼對於initialize
這個特定控件還需要其他一些步驟。這些用於Windows Phone的
ConventionManager.AddElementConvention<RadDataBoundListBox>(DataControlBase.ItemsSourceProperty, "ItemsSource", "SelectionChanged");
ConventionManager.AddElementConvention<RadDockPanel>(RadDockPanel.DockProperty, "Dock", "DockChanged");
ConventionManager.AddElementConvention<RadListPicker>(ItemsControl.ItemsSourceProperty, "ItemsSource", "SelectionChanged");
ConventionManager.AddElementConvention<RadDatePicker>(DateTimePicker.ValueProperty, "Value", "ValueChanged");
ConventionManager.AddElementConvention<RadTimePicker>(DateTimePicker.ValueProperty, "Value", "ValueChanged");
ConventionManager.AddElementConvention<RadToggleSwitch>(RadToggleSwitch.IsCheckedProperty, "IsChecked", "CheckChanged");
ConventionManager.AddElementConvention<RadContextMenuItem>(RadContextMenuItem.CommandProperty, "Command", "Tap");
ConventionManager.AddElementConvention<RadHubTile>(HubTileBase.CommandProperty, "Command", "Tap");
爲Telerik的UI定製公約
http://caliburnmicro.com/documentation/conventions
的例子是非常基本的,但讓他們開展相應的工作。
ConventionManager.AddElementConvention<Pivot>(ItemsControl.ItemsSourceProperty, "SelectedItem", "SelectionChanged").ApplyBinding =
(viewModelType, path, property, element, convention) =>
{
if (ConventionManager
.GetElementConvention(typeof(ItemsControl))
.ApplyBinding(viewModelType, path, property, element, convention))
{
ConventionManager
.ConfigureSelectedItem(element, Pivot.SelectedItemProperty, viewModelType, path);
ConventionManager
.ApplyHeaderTemplate(element, Pivot.HeaderTemplateProperty, null, viewModelType);
return true;
}
return false;
};
更多涉及到的ItemsControl的的SelectedItem先進約定......
正如你可以看到它完全依賴於控件本身並暴露於使用可用DependencyProperties。