<local:DataBaseSettings>
<Grid>
<DataGrid ItemsSource="{Binding Printers}">
<DataGrid.Columns>
<DataGridComboBoxColumn Header="Drucker Typ"
ItemsSource="{Binding RelativeSource={RelativeSource AncestorType={x:Type local:DataBaseSettings}}, Path=PrinterTypes}"
SelectedItem="{Binding PrinterType, Mode=TwoWay}" />
</DataGrid.Columns>
</DataGrid>
</Grid>
</local:DataBaseSettings>
Обратите внимание, что если каждый Printer.PrinterType
непосредственно не ссылается на элемент, который существует в DataContext вашего окна, вам нужно перезаписать метод .Equals()
вашего класса PrinterType
, чтобы сделать эти два элемента равными.
Что-то вроде
public override bool Equals(object obj)
{
if (obj == null) return false;
if (this.GetType() != obj.GetType()) return false;
PrinterType printerType= (PrinterType)obj;
return (this.Id == printerType.Id);
}