Skip to content

Conversation

@PatrickAgeev
Copy link
Contributor

Bind Column With !
Add CellStyle -ClassStyle
Add HeaderStyle -ClassStyle
Repaing EmptyView to Height

Bind Column With !
Add CellStyle   -ClassStyle
Add HeaderStyle  -ClassStyle
Repaing EmptyView to Height
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds style class support for DataGrid cells and headers, introduces a converter for column width binding, and modifies the row definition logic to better handle empty views. The changes aim to enhance the styling capabilities of the DataGrid control and improve the rendering of empty states.

Changes:

  • Added ApplyStyleClassToView method to apply style classes to header and cell views
  • Modified column width binding to use a converter with two-way binding support
  • Updated row definitions to allocate a star-sized row for empty views when only headers are present

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +206 to +210
if (!string.IsNullOrEmpty(column.HeaderStyleClass))
{
ApplyStyleClassToView(titleView, column.HeaderStyleClass, new List<string> { "DataGridHeaderColumn"});

}
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The property 'HeaderStyleClass' does not exist in the DataGridColumn class. This will cause a compilation error. You need to add this property to the DataGridColumn class before using it here.

Suggested change
if (!string.IsNullOrEmpty(column.HeaderStyleClass))
{
ApplyStyleClassToView(titleView, column.HeaderStyleClass, new List<string> { "DataGridHeaderColumn"});
}

Copilot uses AI. Check for mistakes.
private void ApplyStyleClassToView(View view, string styleClasses,List<string> extClasses)
{
if (view == null) return;
List<string> nc=new List<string>();
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent spacing in variable declaration. There are two spaces before 'nc=', and no spaces around the assignment operator. It should be 'List nc = new List();' with proper spacing, consistent with C# conventions seen elsewhere in the codebase.

Suggested change
List<string> nc=new List<string>();
List<string> nc = new List<string>();

Copilot uses AI. Check for mistakes.
BindingContext = item,
};

ApplyStyleClassToView(cell, column.CellStyleClass, new List<string> { "DataGridCellColumn"});
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The property 'CellStyleClass' does not exist in the DataGridColumn class. This will cause a compilation error. You need to add this property to the DataGridColumn class before using it here.

Suggested change
ApplyStyleClassToView(cell, column.CellStyleClass, new List<string> { "DataGridCellColumn"});
ApplyStyleClassToView(cell, null, new List<string> { "DataGridCellColumn" });

Copilot uses AI. Check for mistakes.
// Создайте ресурс конвертера
var converter = new UniversalGridLengthConverter();

var columnDefinition = new ColumnDefinition();
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect indentation. This line has inconsistent indentation with extra leading spaces. The 'var columnDefinition' declaration should be aligned with the other statements inside the for loop.

Suggested change
var columnDefinition = new ColumnDefinition();
var columnDefinition = new ColumnDefinition();

Copilot uses AI. Check for mistakes.
new Binding("Width", source: Columns[i])
{
Converter = converter,
Mode = BindingMode.TwoWay // если нужно двустороннее связывание
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inline comment in Russian '// если нужно двустороннее связывание' is inconsistent with the rest of the codebase, which uses English comments. It should be translated to English, such as '// if two-way binding is needed'. Additionally, the comment suggests uncertainty about whether two-way binding is needed, which should be clarified.

Copilot uses AI. Check for mistakes.
using System.ComponentModel.DataAnnotations;
using System.Reflection;
using UraniumUI.Extensions;
using UraniumUI.Material.Converters;
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The namespace 'UraniumUI.Material.Converters' does not exist in the codebase. The UniversalGridLengthConverter class referenced in this import and used on line 318 has not been defined or added in this PR. This will cause a compilation error. You need to either create this converter class or use an existing GridLength converter.

Copilot uses AI. Check for mistakes.
@@ -1,3 +1,4 @@

Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An unnecessary empty line has been added at the beginning of the file. This should be removed to maintain consistency with C# file conventions.

Suggested change

Copilot uses AI. Check for mistakes.
}


private void ApplyStyleClassToView(View view, string styleClasses,List<string> extClasses)
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing space after the comma in the parameter list. The parameter should be 'List extClasses' with a space after the comma, consistent with C# formatting conventions.

Suggested change
private void ApplyStyleClassToView(View view, string styleClasses,List<string> extClasses)
private void ApplyStyleClassToView(View view, string styleClasses, List<string> extClasses)

Copilot uses AI. Check for mistakes.
Comment on lines +317 to +329
// Создайте ресурс конвертера
var converter = new UniversalGridLengthConverter();

var columnDefinition = new ColumnDefinition();
// Set the binding

// Устанавливаем привязку с конвертером
columnDefinition.SetBinding(
ColumnDefinition.WidthProperty,
new Binding("Width", source: Columns[i])
{
Converter = converter,
Mode = BindingMode.TwoWay // если нужно двустороннее связывание
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comments in Russian are inconsistent with the rest of the codebase, which uses English comments. The comment '// Создайте ресурс конвертера' should be translated to English, such as '// Create converter resource'.

Suggested change
// Создайте ресурс конвертера
var converter = new UniversalGridLengthConverter();
var columnDefinition = new ColumnDefinition();
// Set the binding
// Устанавливаем привязку с конвертером
columnDefinition.SetBinding(
ColumnDefinition.WidthProperty,
new Binding("Width", source: Columns[i])
{
Converter = converter,
Mode = BindingMode.TwoWay // если нужно двустороннее связывание
// Create converter resource
var converter = new UniversalGridLengthConverter();
var columnDefinition = new ColumnDefinition();
// Set the binding
// Set the binding with the converter
columnDefinition.SetBinding(
ColumnDefinition.WidthProperty,
new Binding("Width", source: Columns[i])
{
Converter = converter,
Mode = BindingMode.TwoWay // if two-way binding is needed

Copilot uses AI. Check for mistakes.
@@ -210,12 +216,26 @@ protected virtual void AddTableHeaders(int row = 0)
// TODO: Use an attribute to localize it.
titleView.BindingContext = column;
titleView.SetBinding(View.IsVisibleProperty, nameof(DataGridColumn.IsVisible));
Copy link

Copilot AI Jan 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removal of the Width binding from titleView appears to be intentional as the width is now handled at the ColumnDefinition level (lines 324-330). However, this changes the behavior: previously, individual header views could have their own width, but now the width is controlled by the column definition. Ensure this is the intended behavior and that it doesn't break existing usage where individual header views may have had custom widths.

Suggested change
titleView.SetBinding(View.IsVisibleProperty, nameof(DataGridColumn.IsVisible));
titleView.SetBinding(View.IsVisibleProperty, nameof(DataGridColumn.IsVisible));
titleView.SetBinding(View.WidthRequestProperty, nameof(DataGridColumn.Width));

Copilot uses AI. Check for mistakes.
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

Successfully merging this pull request may close these issues.

1 participant