Hi,
This is the first time I am using Infragistics WPF control in my WPF application for better performance. I have the following WPF code, where the used WPF DataGrid need to be replaced with Infragistics grid and not getting which one i need to use xamGrid or xamDatagrid.
Below is the WPF code i need to achieve through infragistics control.
<DataGrid Name="dgActivities" MaxHeight="325" EnableColumnVirtualization="True" EnableRowVirtualization="True" HorizontalAlignment="Stretch" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Auto" ItemsSource="{Binding ActivityList,IsAsync=True}" RowStyle="{StaticResource DataGridRowStyleForTransactionGrid}" > <DataGrid.Columns> <DataGridTemplateColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False" > <DataGridTemplateColumn.HeaderTemplate> <DataTemplate> <CheckBox Name="chbxSelectAll" Style="{StaticResource CheckBoxSelectTypeStyle2}" IsChecked="{Binding DataContext.CheckAllSelected, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/> </DataTemplate> </DataGridTemplateColumn.HeaderTemplate> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <StackPanel> <CheckBox IsChecked="{Binding IsActivitySelected, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Style="{StaticResource CheckBoxSelectTypeStyle}" /> </StackPanel> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> <DataGridTemplateColumn x:Name="statusCol" Header="Status" Width="0.25*" HeaderStyle="{StaticResource DataGridColumnHeaderStyleActivityList}" CanUserReorder="False" CanUserResize="False" CanUserSort="False"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <StackPanel HorizontalAlignment="Left"> <Border CornerRadius="2" Margin="0"> <Border.Background> <MultiBinding Converter="{StaticResource colorchangeconv}" ConverterParameter="Status"> <Binding Path="Status"/> <Binding Path="DueDate"/> </MultiBinding> </Border.Background> <TextBlock x:Name="statuslbl" Text="{Binding Status}" Width="50" Height="20" TextAlignment="Center" FontSize="12" Foreground="#FFFFFF" VerticalAlignment="Center" HorizontalAlignment="Right" FontFamily="{StaticResource FontNormal}"/> </Border> </StackPanel> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> <DataGridTemplateColumn x:Name="createdDateCol" Header="Date Created" HeaderStyle="{StaticResource DataGridColumnHeaderStyleActivityList}" Width="0.3*" SortMemberPath="CreatedDate" SortDirection="{x:Null}" CanUserReorder="False" CanUserResize="False" CanUserSort="True"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding CreatedDate, StringFormat=\{0:MM/dd/yyyy\}}" FontSize="12" FontFamily="{StaticResource FontNormal}" VerticalAlignment="Center" TextWrapping="Wrap"/> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> <DataGridTemplateColumn x:Name="dueDateCol" Header="Due Date" HeaderStyle="{StaticResource DataGridColumnHeaderStyleActivityList}" Width="0.3*" SortMemberPath="DueDate" SortDirection="{x:Null}" CanUserReorder="False" CanUserResize="False" CanUserSort="True"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding DueDate, StringFormat=\{0:MM/dd/yyyy\}}" VerticalAlignment="Center" FontSize="12" FontFamily="{StaticResource FontNormal}" TextWrapping="Wrap"> <TextBlock.Foreground> <MultiBinding Converter="{StaticResource colorchangeconv}" ConverterParameter="Date"> <Binding Path="Status"/> <Binding Path="DueDate"/> </MultiBinding> </TextBlock.Foreground> </TextBlock> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> <DataGridTemplateColumn x:Name="priorityCol" Header="!" HeaderStyle="{StaticResource DataGridColumnHeaderStyleActivityList}" SortMemberPath="Priority.PriorityDescription" SortDirection="{x:Null}" CanUserReorder="False" CanUserResize="False" CanUserSort="True"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Priority.PriorityDescription, Converter={StaticResource textConverter}}" Foreground="#FF0000" FontSize="12" FontFamily="{StaticResource FontNormal}"/> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> <DataGridTemplateColumn x:Name="topicCol" Header="Topic" HeaderStyle="{StaticResource DataGridColumnHeaderStyleActivityList}" Width="0.8*" SortMemberPath="Topic" SortDirection="{x:Null}" CanUserReorder="False" CanUserResize="False" CanUserSort="True"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Topic}" FontSize="12" FontFamily="{StaticResource FontNormal}" TextWrapping="Wrap" /> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> <DataGridTemplateColumn SortMemberPath="CustomerName" HeaderStyle="{StaticResource DataGridColumnHeaderStyleActivityList}" Width="0.9*" SortDirection="{x:Null}" Header="Customer/Prospect Name" CanUserSort="True" CanUserReorder="False" CanUserResize="False"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <Button Style="{StaticResource NoChromeButton}" HorizontalAlignment="Left"> <Hyperlink Style="{StaticResource hypeCustPros}" Command="{Binding DataContext.PopulateCustProspectActivity, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}" CommandParameter="{Binding}"> <InlineUIContainer> <TextBlock Text="{Binding CustomerName}" Cursor="Hand" FontSize="12" FontFamily="{StaticResource FontBold}"/> </InlineUIContainer> </Hyperlink> </Button> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> <DataGridTemplateColumn x:Name="branchCol" Header="Branch" HeaderStyle="{StaticResource DataGridColumnHeaderStyleActivityList}" Width="0.2*" SortMemberPath="Branch" SortDirection="{x:Null}" CanUserReorder="False" CanUserResize="False" CanUserSort="True"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Branch}" FontSize="12" VerticalAlignment="Center" TextWrapping="Wrap" /> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> <DataGridTemplateColumn x:Name="assignedToCol" HeaderStyle="{StaticResource DataGridColumnHeaderStyleActivityList}" Header="Assigned To" Width="*" SortMemberPath="AssignedTo" SortDirection="{x:Null}" CanUserReorder="False" CanUserResize="False" CanUserSort="True"> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding AssignedTo}" FontSize="12" FontFamily="{StaticResource FontNormal}" TextWrapping="Wrap" /> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn> </DataGrid.Columns> </DataGrid>
Please let me know how do i need to add style to the header field whether it is checkbox or text.Since i need to use IValueconverter, so please let me know which will be preferable to use.
Thanks & Regards,
Sanjay
Hello Sanjay,
Thank you for your post. I have been looking into it and I can say that in both XamDataGrid and XamGrid you can have templated headers. The XamGrid structure is similar to the MS DataGrid, you have different columns and they have HeaderTemplate. The XamDataGrid has Field and the Field’s Settings Property has LabelPresenterStyle Property of type Style (of LabelPresenter). Please let me know if this helps you or you have further questions on this matter.
Looking forward for your reply.
Hi Stefan,
Thanks for your response. I am using xamGrid and i am facing a problem to get the CheckBoxes in each row with a specific style. I am able to get the Header Checkbox with a style but not the Checkboxes inside the cell.
I am doing like below:
<ig:XamGrid ItemsSource="{Binding Path=ActivityList}" AutoGenerateColumns="false" > <ig:XamGrid.Columns> <ig:CheckBoxColumn Key="IsChecked" CellStyle="{StaticResource CheckBoxSelectTypeStyle}" > <ig:CheckBoxColumn.HeaderTemplate> <DataTemplate> <CheckBox Name="chbxSelectAll" Style="{StaticResource CheckBoxSelectTypeStyle2}" IsChecked="{Binding DataContext.CheckAllSelected, RelativeSource={RelativeSource AncestorType={x:Type ig:XamGrid}}}"/> </DataTemplate> </ig:CheckBoxColumn.HeaderTemplate> </ig:CheckBoxColumn> </ig:XamGrid.Columns> </ig:XamGrid>
But I am not getting Checkboxes in cell with style.I need to achieve the following with XamGrid.
<DataGridTemplateColumn CanUserReorder="False" CanUserResize="False" CanUserSort="False" > <DataGridTemplateColumn.HeaderTemplate> <DataTemplate> <CheckBox Name="chbxSelectAll" Style="{StaticResource CheckBoxSelectTypeStyle2}" IsChecked="{Binding DataContext.CheckAllSelected, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}}"/> </DataTemplate> </DataGridTemplateColumn.HeaderTemplate> <DataGridTemplateColumn.CellTemplate> <DataTemplate> <StackPanel> <CheckBox IsChecked="{Binding IsActivitySelected, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}" Style="{StaticResource CheckBoxSelectTypeStyle}" /> </StackPanel> </DataTemplate> </DataGridTemplateColumn.CellTemplate> </DataGridTemplateColumn>
Please let me know how can i achieve the same with XamGrid.
Thanks.
Instead of CheckBoxColumn you can use TemplateColumn which has ItemTemplate Proeprty similar to DataGridTemplateColumn's CellTemplate. Please let me know if this helps you or you have further questions on this matter.
I have used ItemTemplate but getting performance issue. I have posted the same in the following link:
http://www.infragistics.com/community/forums/t/93505.aspx
Need your help urgently.
I got the solution for the issue. Dont know why but after putting MaxHeight in the xamGrid Performance is much better(2 secs for 10000 recs).