<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>
Note that if each Printer.PrinterType does not refer directly to an element that exists in your WindowContext Window, you need to overwrite the .Equals() method of your PrinterType class to make the two elements equal.
Sort of
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); }
source share