{"id":2709,"date":"2022-10-11T21:36:01","date_gmt":"2022-10-11T21:36:01","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=2709"},"modified":"2022-10-11T21:36:01","modified_gmt":"2022-10-11T21:36:01","slug":"a-few-tips-and-tricks-for-using-infragistics-xamdatagrid","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/a-few-tips-and-tricks-for-using-infragistics-xamdatagrid\/","title":{"rendered":"A few tips and tricks for using Infragistics XamDataGrid"},"content":{"rendered":"<p><em>Note: This post was written a while back but sat in draft. I&#8217;ve published this now, but I&#8217;m not sure it&#8217;s relevant to the latest versions etc. so please bear this in mind.<\/em><\/p>\n<p>I&#8217;m working on a project using the XamDataGrid. I&#8217;ve used the UltraWinGrid by Infragistics in the past but that doesn&#8217;t help at all when moving code from Windows Formds to WPF. So here&#8217;s a list of a few commonly required features and how to do them using the XamDataGrid.<\/p>\n<p><em>Note: this post only refers to using version 12.2<\/em><\/p>\n<p><strong>Grid lines<\/strong><\/p>\n<p><em>Problem:<\/em> By default there are no grid lines on the XamDataGrid.<\/p>\n<p><em>Solution:<\/em> In your ResourceDictionary (within Generic.xaml or wherever you prefer) add the following<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;Style TargetType=&quot;{x:Type igDP:CellValuePresenter}&quot;&gt;\r\n   &lt;Setter Property=&quot;BorderThickness&quot; Value=&quot;0,0,1,1&quot; \/&gt;\r\n   &lt;Setter Property=&quot;BorderBrush&quot; Value=&quot;{x:Static SystemColors.ControlLightBrush}&quot; \/&gt;\r\n&lt;\/Style&gt;\r\n<\/pre>\n<p>Obviously replace the BorderBrush colour with your preferred colour.<\/p>\n<p><strong>Remove the group by area<\/strong><\/p>\n<p><em>Problem:<\/em> I want to remove the group by section from the XamDataGrid.<\/p>\n<p><em>Solution:<\/em> In your ResourceDictionary (within Generic.xaml or wherever you prefer) add the following<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;Style x:Key=&quot;IceGrid&quot; TargetType=&quot;igDP:XamDataGrid&quot;&gt;\r\n   &lt;Setter Property=&quot;GroupByAreaLocation&quot; Value=&quot;None&quot; \/&gt;\r\n&lt;\/Style&gt;\r\n<\/pre>\n<p>don&#8217;t forget to apply the style to your grid, i.e.<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;dp:XamDataGrid Style=&quot;{StaticResource IceGrid}&quot; DataSource=&quot;{Binding Details}&quot;&gt;\r\n   &lt;!- Your grid code --&gt;\r\n&lt;\/dp:XamDataGrid&gt;\r\n<\/pre>\n<p><strong>Column formatting<\/strong><\/p>\n<p><em>Problem:<\/em> We want to change the numerical formatting for a column<\/p>\n<p><em>Solution:<\/em> We can set the EditorStyle for a field (editor doesn&#8217;t mean it will make the field editable)<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;dp:XamDataGrid.FieldLayouts&gt;\r\n   &lt;dp:FieldLayout&gt;\r\n      &lt;dp:FieldLayout.Fields&gt;\r\n         &lt;dp:Field Name=&quot;fee&quot; Label=&quot;Fee&quot; Width=&quot;80&quot;&gt;\r\n            &lt;dp:Field.Settings&gt;\r\n               &lt;dp:FieldSettings&gt;\r\n                  &lt;dp:FieldSettings.EditorStyle&gt;\r\n                     &lt;Style TargetType=&quot;{x:Type editors:XamNumericEditor}&quot;&gt;\r\n                        &lt;Setter Property=&quot;Format&quot; Value=&quot;0.####&quot; \/&gt;\r\n                     &lt;\/Style&gt;\r\n                  &lt;\/dp:FieldSettings.EditorStyle&gt;\r\n               &lt;\/dp:FieldSettings&gt;\r\n           &lt;\/dp:Field.Settings&gt;\r\n        &lt;\/dp:Field&gt;         \r\n      &lt;\/dp:FieldLayout.Fields&gt;\r\n   &lt;\/dp:FieldLayout&gt;\r\n&lt;\/dp:XamDataGrid.FieldLayouts&gt;\r\n<\/pre>\n<p>This code creates a field named <em>fee<\/em> and with the label <em>Fee<\/em> and the editor is set to only display decimal places if they actually exist.<\/p>\n<p>As we&#8217;re defining the fields you&#8217;ll need to turn off auto generation of fields, as per<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;dp:XamDataGrid.FieldLayoutSettings&gt;\r\n   &lt;dp:FieldLayoutSettings AutoGenerateFields=&quot;False&quot; \/&gt;\r\n&lt;\/dp:XamDataGrid.FieldLayoutSettings&gt;\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Note: This post was written a while back but sat in draft. I&#8217;ve published this now, but I&#8217;m not sure it&#8217;s relevant to the latest versions etc. so please bear this in mind. I&#8217;m working on a project using the XamDataGrid. I&#8217;ve used the UltraWinGrid by Infragistics in the past but that doesn&#8217;t help at [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[84,13,85],"tags":[],"class_list":["post-2709","post","type-post","status-publish","format-standard","hentry","category-infragistics","category-wpf","category-xamdatagrid"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/2709","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=2709"}],"version-history":[{"count":4,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/2709\/revisions"}],"predecessor-version":[{"id":9600,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/2709\/revisions\/9600"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=2709"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=2709"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=2709"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}