<DataTemplate>
<StackPanel Orientation="Vertical" Name="AddressStackPanel" >
<ComboBox Name="ComboBox" ItemsSource="{Binding Path=MatchedAddressList}" DisplayMemberPath="Address" SelectedIndex="0" SelectionChanged="ComboBox_SelectionChanged"/>
<TextBlock Name="InputtedAddress" Text="{Binding Path=InputtedAddress}" Foreground={Hopefully pass the UI element to the dataconverter } />
</StackPanel>
</DataTemplate>
ComboBox 具有与所选得分值最高的地理数据库匹配的地址。文本块具有用于匹配的用户输入地址。如果地址相同,我希望前景为绿色,否则为红色。
我想也许我可以将整个 TextBlock 传递给数据转换器,获取其父 StackPanel,获取子 0,转换为 Combobox 获取第 0 个元素并进行比较,然后返回红色或绿色。这是可行的吗?
否则我想我必须遍历我认为丑陋的视觉树