您必须添加自定义约定才能绑定到基于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。