私はこれをStackOverflowですでに見つけたと確信していますが、もう一度見つけるほど賢くないようです
私がやりたいことは(MVVMを使用してWPFで)これです:
cmbSelectedAddressRegion: populated with the list of region
cmbSelectedAddressCities: populated with the list of cities in that region
cmbSelectedAddressRegionユーザーがアイテムの地域をクリックすると、cmbSelectedAddressCitiesその地域の都市のみが表示されます
私はこのようなXAMLを持っています
<ComboBox Name="cmbSelectedAddressRegion"
SelectedValue="{Binding Path=selectedAddressItemRegion, UpdateSourceTrigger=PropertyChanged}"
IsEnabled="{Binding Path=selectedAddressIsEnabled}"
Style="{StaticResource style_flat_ComboBox}"></ComboBox>
<ComboBox Name="cmbSelectedAddressCities"
SelectedValue="{Binding Path=selectedAddressIdCities, UpdateSourceTrigger=PropertyChanged}" DisplayMemberPath="id"
SelectedValuePath="id"
ItemsSource="{Binding ElementName=cmbSelectedAddressRegion, Path=SelectedItem.Cities}" IsEnabled="{Binding Path=selectedAddressIsEnabled}"
Style="{StaticResource style_flat_ComboBox}"></ComboBox>
cmbSelectedAddressRegion の領域をクリックすると、cmbSelectedAddressCities が正しく設定されます
vmCustomerまた、多くのVM があります(DependencyPropertiesそれらの中でselectedAddressItemRegionもselectedAddressIdCities)cmbSelectedAddressRegionの何かcmbSelectedAddressCities。もう一度クリックするとcmbSelectedAddressRegion、cmbSelectedAddressCitiesデータが入力され、現在選択されている都市 ( 内vmCustomer) が選択されます。
はcmbSelectedAddressRegion.itemssource(ファイルの背後にあるボードで) にバインドされてObservableCollection(of vmAddressRegion)
いvmAddressRegionますcities。ObservableCollection(of vmAddressCities)
ウィンドウのObservableCollection(of vmAddressRegion)作成時にデータが取り込まれます。同時に、ObservableCollection(of vmAddressRegion)(タイプ のvmAddressRegion) のすべてのアイテムに対してObservableCollection(of vmAddressCities)、 に対応するアイテムが入力されます)
上記の問題(cmbSelectedAddressCities「入力されていない」)を解決する方法について何か提案はありますか?
助けてくれてありがとう