UserTypesObservableCollectionを内部に持つ"Settings"オブジェクトからItemsSourceを取得するComboBoxがあり、そのSelectedItemを"Employee"オブジェクトのtypeプロパティにバインドする必要があります。ウィンドウ内には他のフィールドがあり、「Employee」オブジェクトの他のプロパティに適切にバインドされ、ItemsSourceにはSettings内のUserTypesプロパティが正しく入力され、機能していないのは、コンボとバインドされていないtypeプロパティだけです。 'x selecteditem、おそらくそのdatacontextが"Settings"オブジェクトに設定されているため。これが私がこれまでに持っているものです:
<CollectionViewSource x:Key="settingsViewSource" d:DesignSource="{d:DesignInstance my:Settings, CreateList=True}" />
<CollectionViewSource x:Key="settingsUserTypesViewSource" Source="{Binding Path=UserTypes, Source={StaticResource settingsViewSource}}" />
<ComboBox DataContext="{StaticResource settingsUserTypesViewSource}" Name="userTypeBox" VerticalAlignment="Top" Width="100" Margin="2" ItemsSource="{Binding}"
SelectedItem="{Binding Path=Type, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}">
背後にあるコードでは、私は持っています:
InitializeComponent();
this.emp = emp;
InfoTab.DataContext = emp;
userTypeBox.DataContext = MainWindow.ViewSettings.UserTypes;
empは、フィールドに正しくバインドされた特定の従業員であり、コンボボックスの選択されたアイテムのみが機能していません。どんな助けでも大歓迎です。