これを行う 1 つの方法は、ComboBox の ItemsSource を ListBox の SelectedValue プロパティにバインドすることです。これが機能するには、ComboBox がバインドされる項目のリストを含む項目のコレクションに ListBox をバインドする必要があります。
<ListBox
x:Name="CategoryList"
ItemsSource="{Binding Path=MasterList,
RelativeSource={RelativeSource AncestorType=Window}}"
DisplayMemberPath="MasterProperty"
SelectedValuePath="Details"
/>
<ComboBox
ItemsSource="{Binding Path=SelectedValue, ElementName=CategoryList}"
DisplayMemberPath="DetailProperty"
Grid.Row="1"
/>
この例では、Details コレクションを含むオブジェクトのリストを公開するウィンドウのコード ビハインドでパブリック プロパティを作成しました。
public List<Master> MasterList { get; set; }
public class Master
{
public string MasterProperty { get; set; }
public List<Detail> Details { get; set; }
}
public class Detail
{
public string DetailProperty { get; set; }
}