GridView inserting unexpected margins for its columns.
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.
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?
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?
-
sfernandez
Site Admin
- Posts: 2984
- Joined:
Re: GridView inserting unexpected margins for its columns.
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
If you need to remove that margin you can set negative values in your cell template root:
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
Code: Select all
cell.Margin = _defalutCellMargin; // = new Thickness(6, 0, 6, 0);
Code: Select all
<DataTemplate x:Key="CellTemplate">
<Grid Margin="-6,0">...</Grid>
</DataTemplate>
Re: GridView inserting unexpected margins for its columns.
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!
-
sfernandez
Site Admin
- Posts: 2984
- Joined:
Re: GridView inserting unexpected margins for its columns.
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 8 guests