I have a converter which has a couple of input variables (an object and a TextBox) and then returns the TextBox.Text
String property.
The problem I'm running into is in the ConvertBack()
Method of my converter. I have no way of linking any updates back to the object since all I get is a String (the Text of the Textbox). Is there some way I can access some (if not all) the Convert()
variables? Or at least know which textbox is calling ConvertBack()
?
Here is my ItemsControl Code:
<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>
And here's a snippet from my Converter:
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;