0

コンボボックスの選択した値をリストビュー列の値にバインドする際に問題が発生しています。

マイ リストビューには、コレクション ビューソースである Inquiries のデータ コンテキストがあります コレクション ビューソースでもあるアカウントのデータ コンテキストとしての ComboBox

itemssource を {Binding} に設定することで、どちらもリストを正しく表示します

私がする必要があるのは、Combobox selectedvalue を、それが置かれている Inquiries 行にバインドすることです。

アカウント列の XAML は次のとおりです。

<GridViewColumn x:Name="AccountIdColumn" Header="Account" Width="80">
    <GridViewColumn.CellTemplate>
        <DataTemplate>
            <ComboBox Margin="-6,-1" DataContext="{StaticResource AccountViewSource}" 
                                      ItemsSource="{Binding}"
                                      x:Name="AccountComboBox"
                                      SelectedValuePath="ID" 
                                      DisplayMemberPath="Description" 
                                      Height="Auto" 
                                      SelectedValue="{Binding AccountID, Mode=TwoWay, NotifyOnValidationError=true, ValidatesOnExceptions=true, NotifyOnSourceUpdated=True, NotifyOnTargetUpdated=True, UpdateSourceTrigger=PropertyChanged}"/>
       </DataTemplate>
    </GridViewColumn.CellTemplate>
</GridViewColumn>

リストビューは次のように設定されています。

<ListView DataContext="{StaticResource tbl_InquiriesViewSource}" x:Name="Tbl_InquiriesListView" ItemsSource="{Binding Mode=OneWay, NotifyOnSourceUpdated=True, NotifyOnTargetUpdated=True, UpdateSourceTrigger=PropertyChanged}" Margin="10,47,10,10" SelectionMode="Single" SourceUpdated="Tbl_InquiriesListView_SourceUpdated" TargetUpdated="Tbl_InquiriesListView_TargetUpdated" >
        <ListView.ItemContainerStyle>
            <Style>
                <Setter Property="Control.HorizontalContentAlignment" Value="Stretch"/>
                <Setter Property="Control.VerticalContentAlignment" Value="Stretch"/>
            </Style>
        </ListView.ItemContainerStyle>
        <ListView.View>
            <GridView>
                ....

うまくいかない理由はわかっているのですが、うまくいく方法がわかりません。

4

2 に答える 2