我有一个转换器,它有几个输入变量(一个对象和一个文本框),然后返回TextBox.Text
字符串属性。
我遇到的问题出在ConvertBack()
转换器的方法中。我无法将任何更新链接回对象,因为我得到的只是一个字符串(文本框的文本)。有什么方法可以访问一些(如果不是全部)Convert()
变量吗?或者至少知道哪个文本框正在调用ConvertBack()
?
这是我的 ItemsControl 代码:
<ItemsControl x:Name="ItemsControlGrid" ItemsSource="{Binding Path=ProjectOrganLocation.LesionTypes, Source={StaticResource Locator}}" >
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBox Width="75" TextAlignment="Center" >
<TextBox.Text>
<MultiBinding Converter="{StaticResource LesionTypeConverter}" >
<Binding RelativeSource="{RelativeSource AncestorType={x:Type TreeViewItem}}" Path="DataContext.OrganLocation"/>
<Binding RelativeSource="{RelativeSource Self}" Path="." />
</MultiBinding>
</TextBox.Text>
</TextBox>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
这是我的转换器的一个片段:
List<CategoryCode> Lesions = organ.getLesionTypes;
if (organ.OrganDisplayName == organ.CurrentOrgan)
organ.Count++;
else
{
organ.Count = 0;
organ.CurrentOrgan = organ.OrganDisplayName;
}
return organ.Labels[organ.Count].LabelPrefix;