2011-11-11 74 views
2

我们已经创建了一个有一个按钮来清除组合框的选择一个自定义ComboBox控件工作SelectedItem没有。在Google上搜索后,我发现问题的解决方案为here。具体而言,改变的SelectedItem结合TemplateBinding不适合的SelectedItem自定义控制扩展组合框

SelectedItem="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedItem}"

使其正常工作。

为什么SelectedItem上的原始TemplateBinding不工作,而TemplateBinding for ItemsSource工作得很好?

回答

4

一个区别(其中,因为我觉得,你的情况主要的问题)是TemplateBinding总是OneWay,而Binding选择是OneWayTwoWaydepending on the property。 (更多详细信息here。)

您可能会在this discussion找到其他的不同之处。