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

How to bind combo box inside datagrid in wpf with observable collection inside observable collection where parent observable collection is bound to data grid/

$
0
0
<xcdg:DataGridControl x:Name="dgDetails" Grid.Column="0" Grid.Row="6" Grid.ColumnSpan="4" AutoCreateColumns="False"



 Width="Auto" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Auto"



 Height="290" AllowDrop="False" IsDeleteCommandEnabled="False" IsManipulationEnabled="False"



 HorizontalAlignment="Stretch" VerticalAlignment="Stretch" TabIndex="2"



 EditTriggers="SingleClick, CellIsCurrent, RowIsCurrent" CellEditorDisplayConditions="CellIsCurrent" UpdateSourceTrigger="CellContentChanged" AllowDrag="False" AllowDetailToggle="False"><xcdg:DataGridControl.Columns><xcdg:Column FieldName="TaxCalculationDetails.AddLess" Title="ADD/LESS" Width="80"><xcdg:Column.CellContentTemplate><DataTemplate><TextBlock x:Name="tbAddLess" /></DataTemplate></xcdg:Column.CellContentTemplate><xcdg:Column.CellEditor><xcdg:CellEditor><xcdg:CellEditor.EditTemplate><DataTemplate><ComboBox x:Name="cmbAddLess" ItemsSource="{Binding Path=ocTaxCalculationDetails.TaxCalculationDetails.ocAddLess}" Height="25" Width="Auto"



 DisplayMemberPath="ocTaxCalculationDetails.TaxCalculationDetails.ocAddLess.Title" IsEditable="False" ToolTip="Select add/less."



 Text="{xcdg:CellEditorBinding}" SelectedIndex="{xcdg:CellEditorBinding}"



 SelectedValuePath="ocTaxCalculationDetails.TaxCalculationDetails.ocAddLess.Id" /></DataTemplate></xcdg:CellEditor.EditTemplate></xcdg:CellEditor></xcdg:Column.CellEditor></xcdg:Column><xcdg:Column FieldName="TH" Title="TAX HEAD" MinWidth="250"><xcdg:Column.CellContentTemplate><DataTemplate><TextBlock x:Name="tbTaxHead" /></DataTemplate></xcdg:Column.CellContentTemplate><xcdg:Column.CellEditor><xcdg:CellEditor><xcdg:CellEditor.EditTemplate><DataTemplate><ComboBox x:Name="cmbTaxHead" 



 Text="{xcdg:CellEditorBinding}" SelectedValuePath="TaxCalculationDetails.ocTaxHead.Id"



 DisplayMemberPath="TaxCalculationDetails.TaxHead.Title" IsEditable="False"



 ToolTip="Select tax head." Width="Auto"><ComboBox.ItemsSource><Binding Path="TaxCalculationDetails.ocTaxHead" BindsDirectlyToSource="True" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged"></Binding></ComboBox.ItemsSource></ComboBox></DataTemplate></xcdg:CellEditor.EditTemplate></xcdg:CellEditor></xcdg:Column.CellEditor></xcdg:Column></xcdg:DataGridControl.Columns></xcdg:DataGridControl>

I have datagrid defined which is bound to observable collection of some custom type.

dgDetails.ItemsSource = ocTaxCalculationDetails;

Now my observable collection contains one string value and two observable collection of different custom types.
In datagrid I have two columns, which contains combo boxes. I want to bind it to the observable collections which are inside my main observable collection which is bound to the grid. How to do this binding through xaml without using DataGridCollectionViewSource, etc.

My current is as foloows which does not work.



3K


Viewing all articles
Browse latest Browse all 18858

Trending Articles



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