Browse Source

DataGrid: fix row headers (only fluent)

pull/4534/head
Maksym Katsydan 6 years ago
parent
commit
16ce3e78d0
  1. 2
      samples/ControlCatalog/Pages/DataGridPage.xaml
  2. 7
      samples/ControlCatalog/Pages/DataGridPage.xaml.cs
  3. 4
      src/Avalonia.Controls.DataGrid/DataGridCell.cs
  4. 2
      src/Avalonia.Controls.DataGrid/DataGridRowGroupHeader.cs
  5. 20
      src/Avalonia.Controls.DataGrid/Themes/Fluent.xaml

2
samples/ControlCatalog/Pages/DataGridPage.xaml

@ -18,7 +18,7 @@
</StackPanel>
<TabControl Grid.Row="1">
<TabItem Header="DataGrid">
<DataGrid Name="dataGrid1" Margin="12" CanUserResizeColumns="True" CanUserReorderColumns="True">
<DataGrid Name="dataGrid1" Margin="12" CanUserResizeColumns="True" CanUserReorderColumns="True" CanUserSortColumns="True" HeadersVisibility="All">
<DataGrid.Columns>
<DataGridTextColumn Header="Country" Binding="{Binding Name}" Width="6*" />
<DataGridTextColumn Header="Region" Binding="{Binding Region}" Width="4*" />

7
samples/ControlCatalog/Pages/DataGridPage.xaml.cs

@ -13,7 +13,7 @@ namespace ControlCatalog.Pages
this.InitializeComponent();
var dg1 = this.FindControl<DataGrid>("dataGrid1");
dg1.IsReadOnly = true;
dg1.LoadingRow += Dg1_LoadingRow;
var collectionView1 = new DataGridCollectionView(Countries.All);
//collectionView.GroupDescriptions.Add(new PathGroupDescription("Region"));
@ -44,6 +44,11 @@ namespace ControlCatalog.Pages
addButton.Click += (a, b) => collectionView3.AddNew();
}
private void Dg1_LoadingRow(object sender, DataGridRowEventArgs e)
{
e.Row.Header = e.Row.GetIndex() + 1;
}
private void InitializeComponent()
{
AvaloniaXamlLoader.Load(this);

4
src/Avalonia.Controls.DataGrid/DataGridCell.cs

@ -19,7 +19,7 @@ namespace Avalonia.Controls
private Rectangle _rightGridLine;
private DataGridColumn _owningColumn;
bool _isValid;
bool _isValid = true;
public static readonly DirectProperty<DataGridCell, bool> IsValidProperty =
AvaloniaProperty.RegisterDirect<DataGridCell, bool>(
@ -191,7 +191,7 @@ namespace Avalonia.Controls
PseudoClasses.Set(":edited", IsEdited);
// PseudoClasses.Set(":invalid", !IsValid);
PseudoClasses.Set(":invalid", !IsValid);
}
// Makes sure the right gridline has the proper stroke and visibility. If lastVisibleColumn is specified, the

2
src/Avalonia.Controls.DataGrid/DataGridRowGroupHeader.cs

@ -334,7 +334,7 @@ namespace Avalonia.Controls
{
if (_headerElement != null && OwningGrid != null)
{
_headerElement.IsVisible = OwningGrid.AreColumnHeadersVisible;
_headerElement.IsVisible = OwningGrid.AreRowHeadersVisible;
}
}

20
src/Avalonia.Controls.DataGrid/Themes/Fluent.xaml

@ -7,12 +7,10 @@
Color="#3F4346" />
<SolidColorBrush x:Key="DisabledVisualElementBackground"
Color="#8CFFFFFF" />
<SolidColorBrush x:Key="InvalidBrush"
Color="#FFFF00" />
<SolidColorBrush x:Key="FillerGridLinesBrush"
Color="Transparent" />
<StaticResource x:Key="ScrollBarsSeparatorBackground"
ResourceKey="SystemControlPageBackgroundChromeLowBrush" />
ResourceKey="SystemChromeLowColor" />
<StaticResource x:Key="DataGridColumnHeaderForegroundBrush"
ResourceKey="SystemControlForegroundBaseMediumBrush" />
<StaticResource x:Key="DataGridColumnHeaderBackgroundColor"
@ -90,7 +88,7 @@
<StaticResource x:Key="DataGridRowGroupHeaderForegroundBrush"
ResourceKey="SystemControlForegroundBaseHighBrush" />
<StaticResource x:Key="DataGridRowInvalidBrush"
ResourceKey="InvalidBrush" />
ResourceKey="SystemControlErrorTextForegroundBrush" />
<StaticResource x:Key="DataGridCellBackgroundBrush"
ResourceKey="SystemControlTransparentBrush" />
<StaticResource x:Key="DataGridCellFocusVisualPrimaryBrush"
@ -98,7 +96,7 @@
<StaticResource x:Key="DataGridCellFocusVisualSecondaryBrush"
ResourceKey="SystemControlFocusVisualSecondaryBrush" />
<StaticResource x:Key="DataGridCellInvalidBrush"
ResourceKey="InvalidBrush" />
ResourceKey="SystemControlErrorTextForegroundBrush" />
</Styles.Resources>
<Style Selector="DataGridCell">
@ -433,7 +431,7 @@
<Setter Property="MinHeight" Value="32" />
<Setter Property="Template">
<ControlTemplate>
<DataGridFrozenGrid Name="Root"
<DataGridFrozenGrid Name="PART_Root"
MinHeight="{TemplateBinding MinHeight}"
ColumnDefinitions="Auto,Auto,Auto,Auto,*"
RowDefinitions="*,Auto">
@ -492,11 +490,11 @@
StrokeThickness="1" />
</Grid>
<DataGridRowHeader Name="RowHeader"
<DataGridRowHeader Name="PART_RowHeader"
Grid.RowSpan="2"
DataGridFrozenGrid.IsFrozen="True" />
<Rectangle x:Name="BottomGridLine"
<Rectangle x:Name="PART_BottomGridLine"
Grid.Row="1"
Grid.ColumnSpan="5"
Height="1" />
@ -533,13 +531,13 @@
<Setter Property="Stretch" Value="UniformToFill" />
</Style>
<Style Selector="DataGridRowGroupHeader /template/ DataGridFrozenGrid#Root">
<Style Selector="DataGridRowGroupHeader /template/ DataGridFrozenGrid#PART_Root">
<Setter Property="Background" Value="{Binding $parent[DataGridRowGroupHeader].Background}" />
</Style>
<Style Selector="DataGridRowGroupHeader:pointerover /template/ DataGridFrozenGrid#Root">
<Style Selector="DataGridRowGroupHeader:pointerover /template/ DataGridFrozenGrid#PART_Root">
<Setter Property="Background" Value="{DynamicResource DataGridRowGroupHeaderHoveredBackgroundBrush}" />
</Style>
<Style Selector="DataGridRowGroupHeader:pressed /template/ DataGridFrozenGrid#Root">
<Style Selector="DataGridRowGroupHeader:pressed /template/ DataGridFrozenGrid#PART_Root">
<Setter Property="Background" Value="{DynamicResource DataGridRowGroupHeaderPressedBackgroundBrush}" />
</Style>

Loading…
Cancel
Save