いくつかの入力変数(オブジェクトとTextBox)を持ち、TextBox.Text
Stringプロパティを返すコンバーターがあります。
私が遭遇している問題は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;