【发布时间】:2012-07-14 07:36:58
【问题描述】:
我正在尝试绑定依赖于同一 DataTemplate 中的控件的属性。
举例说明:
<DataTemplate>
<StackPanel Orientation="Horizontal">
<ComboBox x:Name="ComboList"
ItemsSource="{Binding StatTypes}"
SelectedItem="{Binding SelectedStatType, Mode=TwoWay, FallbackValue='Select a type'}">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Text}"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBox Grid.Column="1" MinWidth="40" Margin="5">
<TextBox.Text>
<Binding Path="StatValue">
<Binding.Converter>
<converter:PercentageConverter SelectedStatType="{Binding ElementName=ComboList, Path=SelectedItem}" />
</Binding.Converter>
</Binding>
</TextBox.Text>
</TextBox>
</StackPanel>
</DataTemplate>
但PercentageConverter 中的属性从未通过此设置,我不明白为什么。这是命名范围问题吗?如果是这样,我认为这无关紧要,因为它在同一个DataTemplate
如果没有,我做错了什么?
【问题讨论】:
-
你应该在visual studio的输出窗口中看到相关的绑定错误。
标签: c# wpf xaml data-binding