Page 1 of 1

GridView inserting unexpected margins for its columns.

Posted: 07 Jan 2021, 14:50
by peterh
I'm working with upgrading Noesis from 2.2 to 3.0. I am currently having an issue with a GridView inserting margins between its columns in an unexpected way. See the below snip from Inspector for an example. This applies to all GridViews in my application.
Image

I am unable to find any source for that margin in my own code, but the "Local" suggests it's been set either by code behind or in my own XAMLs iirc. I am not familiar enough with the mechanics of GridViews and how they populate their columns to figure out where this margin is set. What am I missing?

Re: GridView inserting unexpected margins for its columns.

Posted: 08 Jan 2021, 10:19
by sfernandez
Hi Peter,

This margin is hard-coded in GridViewRowPresenter and added to each cell it generates. This is to match WPF, as you can see in their source code for CreateCell() method:
https://referencesource.microsoft.com/# ... 9665507a79
cell.Margin = _defalutCellMargin; // = new Thickness(6, 0, 6, 0);
If you need to remove that margin you can set negative values in your cell template root:
<DataTemplate x:Key="CellTemplate">
  <Grid Margin="-6,0">...</Grid>
</DataTemplate>

Re: GridView inserting unexpected margins for its columns.

Posted: 12 Jan 2021, 10:11
by peterh
Wow, that is excessively weird, but I understand that you want to conform to the reference implementations as closely as possible. I'll just implement the workaround then, thanks!

Re: GridView inserting unexpected margins for its columns.

Posted: 15 Jan 2021, 10:43
by sfernandez
Yes, it is weird but necessary to get the same visual representation in Blend and Noesis.