我的自定义控件中有这个依赖项属性:
public static readonly DependencyProperty AutoCompleteServiceProperty =
DependencyProperty.Register(
"AutoCompleteService",
typeof(IAutoCompletable),
typeof(AutoCompleteTextBox),
new PropertyMetadata(new CommonSubstringSuggestion()));
当我将它绑定到我的视图模型属性(类型IAutoCompletable
)时,我有绑定错误:
错误:转换器无法转换类型的值 “WinRTXamlToolkit.Controls.AutoCompleteTextBoxControl.Algorithm.LevenshteinDistance, WinRTXamlToolkit,Version = 1.5.4.3,Culture = neutral, PublicKeyToken = null'键入'IAutoCompletable'; BindingExpression: 路径= 'AutoCompleteAlgorithm' 的DataItem ='WinRTXamlToolkit.Sample.ViewModels.Controls.AutoCompleteTextBoxTestsViewModel, WinRTXamlToolkit.Sample,Version = 1.5.4.3,Culture = neutral, 公钥=空';目标元素是 'WinRTXamlToolkit.Controls.AutoCompleteTextBox'(Name ='null');目标 property是'AutoCompleteService'(输入'IAutoCompletable')。
LevenstheinDistance正在实施IAutoCompletable
,为什么这样的转换会失败?