|
@@ -31,7 +31,7 @@ namespace Avalonia.Controls
|
|
|
/// <summary>
|
|
/// <summary>
|
|
|
/// Displays data in a customizable grid.
|
|
/// Displays data in a customizable grid.
|
|
|
/// </summary>
|
|
/// </summary>
|
|
|
- [PseudoClasses(":invalid")]
|
|
|
|
|
|
|
+ [PseudoClasses(":invalid", ":empty-rows", ":empty-columns")]
|
|
|
public partial class DataGrid : TemplatedControl
|
|
public partial class DataGrid : TemplatedControl
|
|
|
{
|
|
{
|
|
|
private const string DATAGRID_elementRowsPresenterName = "PART_RowsPresenter";
|
|
private const string DATAGRID_elementRowsPresenterName = "PART_RowsPresenter";
|
|
@@ -711,6 +711,7 @@ namespace Avalonia.Controls
|
|
|
|
|
|
|
|
DisplayData = new DataGridDisplayData(this);
|
|
DisplayData = new DataGridDisplayData(this);
|
|
|
ColumnsInternal = CreateColumnsInstance();
|
|
ColumnsInternal = CreateColumnsInstance();
|
|
|
|
|
+ ColumnsInternal.CollectionChanged += ColumnsInternal_CollectionChanged;
|
|
|
|
|
|
|
|
RowHeightEstimate = DATAGRID_defaultRowHeight;
|
|
RowHeightEstimate = DATAGRID_defaultRowHeight;
|
|
|
RowDetailsHeightEstimate = 0;
|
|
RowDetailsHeightEstimate = 0;
|
|
@@ -727,6 +728,8 @@ namespace Avalonia.Controls
|
|
|
CurrentCellCoordinates = new DataGridCellCoordinates(-1, -1);
|
|
CurrentCellCoordinates = new DataGridCellCoordinates(-1, -1);
|
|
|
|
|
|
|
|
RowGroupHeaderHeightEstimate = DATAGRID_defaultRowHeight;
|
|
RowGroupHeaderHeightEstimate = DATAGRID_defaultRowHeight;
|
|
|
|
|
+
|
|
|
|
|
+ UpdatePseudoClasses();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void SetValueNoCallback<T>(AvaloniaProperty<T> property, T value, BindingPriority priority = BindingPriority.LocalValue)
|
|
private void SetValueNoCallback<T>(AvaloniaProperty<T> property, T value, BindingPriority priority = BindingPriority.LocalValue)
|
|
@@ -851,9 +854,27 @@ namespace Avalonia.Controls
|
|
|
// can be set when the DataGrid is not part of the visual tree
|
|
// can be set when the DataGrid is not part of the visual tree
|
|
|
_measured = false;
|
|
_measured = false;
|
|
|
InvalidateMeasure();
|
|
InvalidateMeasure();
|
|
|
|
|
+
|
|
|
|
|
+ UpdatePseudoClasses();
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void ColumnsInternal_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
|
|
|
|
|
+ {
|
|
|
|
|
+ if (e.Action == NotifyCollectionChangedAction.Add
|
|
|
|
|
+ || e.Action == NotifyCollectionChangedAction.Remove
|
|
|
|
|
+ || e.Action == NotifyCollectionChangedAction.Reset)
|
|
|
|
|
+ {
|
|
|
|
|
+ UpdatePseudoClasses();
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ internal void UpdatePseudoClasses()
|
|
|
|
|
+ {
|
|
|
|
|
+ PseudoClasses.Set(":empty-columns", !ColumnsInternal.GetVisibleColumns().Any());
|
|
|
|
|
+ PseudoClasses.Set(":empty-rows", !DataConnection.Any());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private void OnSelectedIndexChanged(AvaloniaPropertyChangedEventArgs e)
|
|
private void OnSelectedIndexChanged(AvaloniaPropertyChangedEventArgs e)
|
|
|
{
|
|
{
|
|
|
if (!_areHandlersSuspended)
|
|
if (!_areHandlersSuspended)
|
|
@@ -1348,7 +1369,6 @@ namespace Avalonia.Controls
|
|
|
internal DataGridColumnCollection ColumnsInternal
|
|
internal DataGridColumnCollection ColumnsInternal
|
|
|
{
|
|
{
|
|
|
get;
|
|
get;
|
|
|
- private set;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
internal int AnchorSlot
|
|
internal int AnchorSlot
|