【发布时间】:2010-04-24 02:38:02
【问题描述】:
我有一个使用DataTemplate 的ComboBox。 DataTemplate 包含一个绑定,它使用 IValueConverter 将枚举值转换为字符串。问题是从未调用过值转换器。如果我在StatusToTextConverter.Convert() 中设置断点,它永远不会被命中。
这是我的 XAML:
<ComboBox ItemsSource="{Binding Path=StatusChoices, Mode=OneWay}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Converter={StaticResource StatusToTextConverter}}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
我认为这就是隐式绑定到 DataTemplate 所呈现的值的方式。我错了吗?
编辑:对于上下文:我打算在 DataTemplate 旁边显示一个 Image TextBox。如果我无法让TextBox 绑定工作,那么我认为Image 也不会工作。
【问题讨论】:
标签: wpf data-binding datatemplate