これは単純なはずですが、見つかりません。Master-Detail Binding によって関連付けられた 2 つの Combobox があります。
<ComboBox Style="{StaticResource FixedSelectionCombo}"
ItemsSource="{Binding ElementName=ControlRoot, Path=Clubs}"
DisplayMemberPath="Name"
SelectedItem="{Binding ElementName=ControlRoot,Path=SelectedClub}">
</ComboBox>
<ComboBox Style="{StaticResource FixedSelectionCombo}"
ItemsSource="{Binding ElementName=ControlRoot, Path=SelectedClub.PlayerLists}"
DisplayMemberPath="Name"
SelectedItem="{Binding ElementName=ControlRoot, Path=SelectedPlayerList}">
</ComboBox>
最初のコンボボックスで項目を選択すると、2 番目のコンボボックスに適切な PlayerList が取り込まれますが、最初の項目が自動的に選択されるようにしたいと考えています。
これはコード ビハインドで簡単に実行できますが、ResourceDictionary に配置できる Style を使用してこれを実現したいと考えています。私は試した:
<Style x:Key="FixedSelectionCombo" TargetType="ComboBox" BasedOn="{StaticResource {x:Type ComboBox}}">
<Setter Property="SelectedIndex" Value="0"/>
</Style>
しかし、これは最初のコンボボックスで新しい選択を行った後ではなく、初めて機能します。
どうすればそれができますか?