I am trying to bind some data to a datagrid using the MVVM pattern with WPF. I have confirmed that the datagrid is populating and indeed, that the specific value (Gender) is populated. I've also tried every fix that I could find online (including other questions on this site) that's why I am seeking out an answer here.
<DataGridTemplateColumn Header="Gender" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox ItemsSource="{Binding Genders}" SelectedItem="{Binding Gender, UpdateSourceTrigger=PropertyChanged}" IsSynchronizedWithCurrentItem="True">
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
Things I've tried: Mode=TwoWay, UpdateSourceTrigger=PropertyChanged", IsSynchronizedWithCurrentItem="True". Although, I am not a super experienced WPF and MVVM programmer, so it could be something simple that I just don't know about. My models seem to be working elsewhere and they implement observable/are in observable collections where applicable.
Edit: I got it sorted out. Here is the code that worked for my issue (in case someone else has a similar problem).
<DataGridTemplateColumn Header="Gender" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<ComboBox ItemsSource="{Binding Path=DataContext.Genders, RelativeSource={RelativeSource FindAncestor, AncestorType = Window}}" SelectedItem="{Binding Gender, UpdateSourceTrigger=PropertyChanged}">
</ComboBox>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>