peterh
Topic Author
Posts: 30
Joined: 13 Mar 2015, 13:50

GridView inserting unexpected margins for its columns.

07 Jan 2021, 14:50

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?
 
User avatar
sfernandez
Site Admin
Posts: 2058
Joined: 22 Dec 2011, 19:20

Re: GridView inserting unexpected margins for its columns.

08 Jan 2021, 10:19

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>
 
peterh
Topic Author
Posts: 30
Joined: 13 Mar 2015, 13:50

Re: GridView inserting unexpected margins for its columns.

12 Jan 2021, 10:11

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!
 
User avatar
sfernandez
Site Admin
Posts: 2058
Joined: 22 Dec 2011, 19:20

Re: GridView inserting unexpected margins for its columns.

15 Jan 2021, 10:43

Yes, it is weird but necessary to get the same visual representation in Blend and Noesis.

Who is online

Users browsing this forum: No registered users and 0 guests