I have a DataTatble with a DataColumn defined as
DataTable dt = new DataTable();
DataColumn dcPrice = new DataColumn("Price");
dcPrice.DataType = typeof(decimal);
dcPrice.DefaultValue = 54;
dt.Columns.Add(dcPrice);
I am binding it with XamDataGrid using
Xamgrid.DataSource = dt.Rows
The code in XAML is
<igDP:Field Name="Price" Label="TaxCode" >
<igDP:Field.Settings>
<igDP:FieldSettings />
</igDP:Field.Settings>
</igDP:Field>
Which is working fine but if I use unbooundfield like below
<igDP:UnboundField Name="Price" Label="Price" BindingPath="Price">
<igDP:UnboundField.Settings>
</igDP:UnboundField.Settings>
</igDP:UnboundField>
Or
<igDP:FieldSettings CellValuePresenterStyle="{StaticResource PriceCellStyle}" />
//Where PriceCellStyle is defined in Resources as
<Style x:Key="PriceCellStyle" TargetType="{x:Type igDP:CellValuePresenter}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}">
<StackPanel x:Name="stackPanel" Orientation="Horizontal">
<TextBox Text="{Binding Path=DataItem.Price}" ></TextBox>
</StackPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
Its not showing the values then
I need to show TextBox in the grid binded with the “Price” column as defined in the datatable
Thanks in Advance.
Rehman Mansoor
Hello Rehman,
Thank you for your post. I have been looking through it and I suggest you set the DataSource of your XamDataGrid to dt.DefaultView, because the dt.Rows doesn’t have references to the Columns of your DataTable. It has two index properties, rowIndex and sectionRowIndex, that indicate where a given row appears, which doesn’t come handy when you want to get a Column of the DataTable. Here is the suggested way of setting a DataTable to the XamDataGrid's DataSource:
http://help.infragistics.com/NetAdvantage/WPF/2011.1/CLR4.0/?page=xamDataPresenter_Binding_a_DataPresenter_Control_to_a_DataSet.html
Please note, we are making efforts to ensure all posts are addressed by an Infragistics expert. We believe that the other community members could benefit from this thread as well.
Feel free to write me if you need further assistance.