I would like to bind third column to a CollectionBindingTwo
property that is within Window's DataContext and not inside DataContext of an Items from CollectionBindingOne
.
By defining the second collection inside <DataGrid>
WPF assumes local scope or something, and points to a property within Items of ItemsSource (CollectionBindingOne
).
<DataGrid DockPanel.Dock="Top" ItemsSource="{Binding CollectionBindingOne}" AutoGenerateColumns="False">
<DataGridTextColumn Header="One" Binding="{Binding PropOne}"/>
<DataGridTextColumn Header="Two" Binding="{Binding PropTwo}"/>
<DataGridComboBoxColumn Header="Three" ItemsSource="{Binding CollectionBindingTwo}"/>
</DataGrid>
For example, this works because ComboBox
is not inside a <DataGrid>
:
<ComboBox IsEditable="True" ItemsSource="{Binding CollectionBindingTwo}"></ComboBox>