XamDataGrid Binding problem
Posted
by Mohammad Mostafizur Rahman
on Stack Overflow
See other posts from Stack Overflow
or by Mohammad Mostafizur Rahman
Published on 2010-05-29T07:14:40Z
Indexed on
2010/05/29
7:22 UTC
Read the original article
Hit count: 1828
I want to bind a cell of a XamDataGrid using ComboBox control through a collection's(CurrentEntity.INVTransactions) property(BatchList) but it does not work. I'm using mvvm pattern.In my code "BatchId" and "BatchList" are the properties of CurrentEntity.INVTransactions collection.
would you please tell me why the comboBox of the xamDataGrid doesn't display the BatchList?
sample code:
<UserControl x:Class="PDCL.ERP.Modules.Inventory.Views.RequisitionList.RequisitionInfoUserControl"
...>
<GroupBox Grid.Column="0" Grid.Row="1" Grid.ColumnSpan="2" Header="Details" VerticalAlignment="Top" Margin="5,0,5,0">
<Grid>
<igDP:XamDataGrid Margin="2" DataSource="{Binding CurrentEntity.INVTransactions}" x:Name="requisitionDeailsGrid" InitializeRecord="requisitionDeailsGrid_InitializeRecord">
<igDP:XamDataGrid.FieldLayoutSettings>
<igDP:FieldLayoutSettings HighlightAlternateRecords="True"
AutoGenerateFields="False"
AllowAddNew="True"
AddNewRecordLocation="OnBottom"
AutoFitMode="Always"
SupportDataErrorInfo="RecordsAndCells"
DataErrorDisplayMode="ErrorIcon"
/>
</igDP:XamDataGrid.FieldLayoutSettings>
<igDP:XamDataGrid.FieldLayouts>
<igDP:FieldLayout>
<igDP:FieldLayout.Fields>
<igDP:Field Name="Remarks" Label="Remarks" Width="Auto">
<igDP:Field.Settings>
<igDP:FieldSettings AllowEdit="True" AllowResize="True"/>
</igDP:Field.Settings>
</igDP:Field>
<igDP:Field Name="BatchId" Label="Batch" Width="Auto">
<igDP:Field.Settings>
<igDP:FieldSettings EditorType="{x:Type igEditors:XamComboEditor}">
<igDP:FieldSettings.EditorStyle>
<Style TargetType="{x:Type igEditors:XamComboEditor}">
<Setter Property="ItemsSource" Value="{Binding INVTransactions.BatchList, RelativeSource = {RelativeSource FindAncestor, AncestorType={x:Type igDP:XamDataGrid}, AncestorLevel=1}}" />
<Setter Property="DisplayMemberPath" Value="BatchName" />
<Setter Property="ValuePath" Value="BatchId" />
</Style>
</igDP:FieldSettings.EditorStyle>
</igDP:FieldSettings>
</igDP:Field.Settings>
</igDP:Field>
<igDP:Field Name="Qty" Label="Qty Supplied" Width="Auto">
<igDP:Field.Settings>
<igDP:FieldSettings AllowEdit="True" AllowResize="True"/>
</igDP:Field.Settings>
</igDP:Field>
</igDP:FieldLayout.Fields>
</igDP:FieldLayout>
</igDP:XamDataGrid.FieldLayouts>
</igDP:XamDataGrid>
</Grid>
</GroupBox>
</UserControl>
The output window shows the error "BindingExpression path error: 'INVTransactions' property not found on 'object' ''XamDataGrid' (Name='requisitionDeailsGrid')'. BindingExpression:Path=INVTransactions.BatchList; DataItem='XamDataGrid' (Name='requisitionDeailsGrid'); target element is 'XamComboEditor' (Name=''); target property is 'ItemsSource' (type 'IEnumerable')"
© Stack Overflow or respective owner