Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] DataGrid styles inconsistencies #363

Open
1 task done
sn4k3 opened this issue Dec 13, 2024 · 0 comments
Open
1 task done

[Bug] DataGrid styles inconsistencies #363

sn4k3 opened this issue Dec 13, 2024 · 0 comments

Comments

@sn4k3
Copy link

sn4k3 commented Dec 13, 2024

Check the following items

  • I have looked up relevant Issue

Description of the issue

Found some inconsistencies in styles of DataGrid

  1. Lack of styles for groups (DataGridCollectionView)
  2. Size of cells are incorrect (Overflowing) causing bad alignment and text out of cell limit
  3. GridLinesVisibility="All" also lacks of styles, making borders white instead of copy the border of the header

image
image

Package Version

6.0.0-beta6

Environment

Windows 11

Expected Behavior

  1. Group expander to have matching style
  2. Cells to have proper bounds
  3. GridLinesVisibility="All" to have matching style

Reproduction

public partial class TestUserControl : UserControl
{
    public class TestClass
    {
        public int Index { get; set; }
        public string Name { get; set; }
        public string Description { get; set; }
        public string Group { get; set; }
    }

    public ObservableCollection<TestClass> TestCollection { get; } =
    [
        new() { Index = 1, Name = "Test 1", Description = "Description 1", Group = "Group 1"},
        new() { Index = 2, Name = "Test 2", Description = "Description 2", Group = "Group 1" },
        new() { Index = 3, Name = "Test 3", Description = "Description 3", Group = "Group 2" },
        new() { Index = 4, Name = "Test 4", Description = "Description 4", Group = "Group 2" },
    ];


    public TestUserControl()
    {
        InitializeComponent();
        DataContext = this;
    }

    protected override void OnLoaded(RoutedEventArgs e)
    {
        base.OnLoaded(e);
        var groupView = new DataGridCollectionView(TestCollection);
        groupView.GroupDescriptions.Add(new DataGridPathGroupDescription("Group"));
        MyGrid.ItemsSource = groupView;
    }
}
<UserControl xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:views="clr-namespace:NetSonar.Avalonia.Views"
             xmlns:suki="https://github.com/kikipoulet/SukiUI"
             mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
             x:Class="NetSonar.Avalonia.Views.TestUserControl"
             x:DataType="views:TestUserControl">
    <UserControl.Styles>
        <Style Selector="DataGridCell.center">
            <Setter Property="HorizontalContentAlignment" Value="Center" />
        </Style>
    </UserControl.Styles>

    <suki:GlassCard>
        <DataGrid Name="MyGrid" GridLinesVisibility="All" ItemsSource="{Binding TestCollection}">
          <DataGrid.Columns>
              <DataGridTextColumn Header="Index" Binding="{Binding Index}" CellStyleClasses="center"/>
              <DataGridTextColumn Header="Name" Binding="{Binding Name}"/>
              <DataGridTextColumn Header="Description" Binding="{Binding Description}"/>
              <DataGridTextColumn Header="Group" Binding="{Binding Group}"/>
          </DataGrid.Columns>
      </DataGrid>
    </suki:GlassCard>
</UserControl>

Additional Information

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant