I am developing a WPF4 app and using DataSet to populate a xamDataGrid (from Infragistics). Here is the xaml for datagrid:
<igDP:XamDataGrid AutoFit="True" BindToSampleData="False" Grid.Column="1" HorizontalAlignment="Center" HorizontalContentAlignment="Center" IsUndoEnabled="True" Margin="0,0,0,40" Name="xamDataGridOrganization" SortRecordsByDataType="True" UndoLimit="2" UseLayoutRounding="True" VerticalAlignment="Bottom" VerticalContentAlignment="Center" Padding="0" Panel.ZIndex="1" MaxWidth="Infinity">
<igDP:XamDataGrid.FieldSettings>
<igDP:FieldSettings AllowEdit="False" AllowGroupBy="True" AllowRecordFiltering="True" />
</igDP:XamDataGrid.FieldSettings>
<igDP:XamDataGrid.FieldLayouts>
<igDP:FieldLayout>
<igDP:FieldLayout.Fields>
<igDP:Field Name="Id" Label="Id"/>
<igDP:Field Name="OrganizationName" Label="Organization" />
<igDP:Field Name="EmailId" Label="Email Address" />
</igDP:FieldLayout.Fields>
</igDP:FieldLayout>
</igDP:XamDataGrid.FieldLayouts>
</igDP:XamDataGrid>
Now the code that I am using to populate the xamDataGrid is :
var adcg = new OrganizationGridTableAdapter();
AddressBookDataSet dbcg = new AddressBookDataSet();
adcg.Fill(dbcg.OrganizationGrid);
//xamDataGridIndividual.DataContext = dbc.Individual;
xamDataGridOrganization.DataSource = dbcg.OrganizationGrid.DefaultView;
Now the my DataTable OrganizationGrid has the fields:
and some other fields ..
I want to change the text in the header and some other properties (width, text-size) .. how can i do this?
As you can see in the XAML code, I defined a FieldLayout with the exact same field names, can i bind a column from my DataTable to a particular field defined by me?
You are already changing your Header by using Label.
<igDP:Field Name="Id" Label="Id"/>
In above xaml, you are alreading binding to "Id" in your DataSource. When it binds, it binds by Name attribute.
You can use FieldSettings to modify look and feel by using styles:
<igDP:Field.Settings>
<igDP:FieldSettings
EditorType="{x:Type Editors:XamDateTimeEditor}"
EditorStyle="{StaticResource ResourceKey=styleDateTime}">
</igDP:FieldSettings>
</igDP:Field.Settings>
and style being:
<Style x:Key="styleDateTime" TargetType="{x:Type Editors:XamDateTimeEditor}">
<Setter Property="Format" Value="dd-MMM-yyyy HH:mm:ss" />
<Setter Property="ValueType" Value="{x:Type System:DateTime}"/>
</Style>
search Infragistics for XamDataGrid.