Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Load combobox data inside datagrid

$
0
0

Hi All,

I hope somone can point me in the right direction here. I have a datagrid which I load from a linq query into an observablecollection. Inside this data grid I have a combobox where I want to be able to select a network and save this value back to the database. At the moment however my combox is empty. I suspect my Relative source is not following up to the Itemsource value of my datagrid. Is there anything incorrect with my xaml? I am using simple code behind not mvvm.

<DataGrid x:Name="dataGridSelected" AutoGenerateColumns="False" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" Height="232" Margin="20,5,20,10" CanUserAddRows="False"><DataGrid.RowHeaderTemplate><DataTemplate><Grid><CheckBox IsChecked="{Binding Path=IsSelected, Mode=TwoWay, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGridRow}}}"/></Grid></DataTemplate></DataGrid.RowHeaderTemplate><DataGrid.Columns>                    <DataGridTextColumn Width="180" Header="Adapter Model"  Binding="{Binding Path=AdapterModel, Mode=OneWay}" IsReadOnly="True"/><DataGridTextColumn Width="60" Header="Slot Port" Binding="{Binding Path=SlotPort, Mode=OneWay}" IsReadOnly="True"/><DataGridTemplateColumn Width="140" Header="Network"><DataGridTemplateColumn.CellTemplate><DataTemplate><ComboBox DisplayMemberPath="Network" SelectedValuePath="IdNetwork" SelectedValue="{Binding IdNetwork}" ItemsSource="{Binding Path=DataContext.Network, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" /></DataTemplate></DataGridTemplateColumn.CellTemplate></DataGridTemplateColumn>


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>