Open
Description
Describe the bug
I am unable to remove the padding in cells. I am however able to remove the padding in the column headers.
Steps to Reproduce
Steps to reproduce the behavior:
- Create a new WinUI App
- Add DataGrid to MainWindow.xaml:
<Window
x:Class="DataGridStyling.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:DataGridStyling"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:controls="using:CommunityToolkit.WinUI.UI.Controls"
xmlns:primitives="using:CommunityToolkit.WinUI.UI.Controls.Primitives"
mc:Ignorable="d">
<controls:DataGrid HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
AutoGenerateColumns="True"
GridLinesVisibility="All"
RowHeight="1"
ItemsSource="{x:Bind _collection}">
<controls:DataGrid.ColumnHeaderStyle>
<Style TargetType="primitives:DataGridColumnHeader">
<Setter Property="MinWidth" Value="0"/>
<Setter Property="MinHeight" Value="0"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="Margin" Value="0"/>
</Style>
</controls:DataGrid.ColumnHeaderStyle>
<controls:DataGrid.RowStyle>
<Style TargetType="controls:DataGridRow">
<Setter Property="MinWidth" Value="0"/>
<Setter Property="MinHeight" Value="0"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="Margin" Value="0"/>
</Style>
</controls:DataGrid.RowStyle>
<controls:DataGrid.CellStyle>
<Style TargetType="controls:DataGridCell">
<Setter Property="MinWidth" Value="0"/>
<Setter Property="MinHeight" Value="0"/>
<Setter Property="Padding" Value="0"/>
<Setter Property="Margin" Value="0"/>
</Style>
</controls:DataGrid.CellStyle>
</controls:DataGrid>
</Window>
- Add data to the DataGrid in MainWindow.cs:
using Microsoft.UI.Xaml;
using System.Collections.ObjectModel;
// To learn more about WinUI, the WinUI project structure,
// and more about our project templates, see: http://aka.ms/winui-project-info.
namespace DataGridStyling
{
/// <summary>
/// An empty window that can be used on its own or navigated to within a Frame.
/// </summary>
public sealed partial class MainWindow : Window
{
public MainWindow()
{
this.InitializeComponent();
for (int i = 0; i < 100; ++i)
{
_collection.Add(new Foo
{
X = i,
Y = i * i,
Z = i * i * i,
});
}
}
class Foo
{
public int X { get; set; }
public int Y { get; set; }
public int Z { get; set; }
}
private ObservableCollection<Foo> _collection = new();
}
}
Expected behavior
The row padding should be removed by the styles just like it was removed in the headers.
Environment
NuGet Package(s):
<PackageReference Include="CommunityToolkit.WinUI" Version="7.0.3" />
<PackageReference Include="CommunityToolkit.WinUI.UI.Controls.DataGrid" Version="7.0.3" />
<PackageReference Include="Microsoft.ProjectReunion" Version="0.8.4" />
<PackageReference Include="Microsoft.ProjectReunion.Foundation" Version="0.8.4" />
<PackageReference Include="Microsoft.ProjectReunion.WinUI" Version="0.8.4" />
Package Version(s):
Windows 10 Build Number:
- Fall Creators Update (16299)
- April 2018 Update (17134)
- October 2018 Update (17763)
- May 2019 Update (18362)
- May 2020 Update (19041)
- October 2020 Update (19042)
App min and target version:
- Fall Creators Update (16299)
- April 2018 Update (17134)
- October 2018 Update (17763)
- May 2019 Update (18362)
- May 2020 Update (19041)
- Insider Build ({build_number})
Device form factor:
- Desktop
- Xbox
- Surface Hub
- IoT
Visual Studio version:
- 2017 (15.{minor_version})
- 2019 (16.11.2)
- 2022 (17.{minor_version})