Browse Source

Updated the Default Theme Control Templates

pull/2109/head
sdoroff 8 years ago
parent
commit
c23f6cb857
  1. 2
      samples/DataGridSample/MainWindow.xaml
  2. 53
      src/Avalonia.DataGrid.Themes.Default/DefaultTheme.xaml
  3. 16
      src/Avalonia.DataGrid/DataGridColumnHeader.cs
  4. 11
      src/Avalonia.DataGrid/DataGridRow.cs

2
samples/DataGridSample/MainWindow.xaml

@ -55,7 +55,7 @@
CellStyleClasses="gdp"/>
</dg:DataGrid.Columns>
</dg:DataGrid>
</TabItem>

53
src/Avalonia.DataGrid.Themes.Default/DefaultTheme.xaml

@ -3,6 +3,7 @@
xmlns:dg="clr-namespace:Avalonia.Controls;assembly=Avalonia.DataGrid"
xmlns:prim="clr-namespace:Avalonia.Controls.Primitives;assembly=Avalonia.DataGrid">
<!--TODO: Validation and Focus-->
<Style Selector="dg|DataGridCell">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
@ -101,6 +102,17 @@
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Margin="{TemplateBinding Padding}">
<ContentPresenter Content="{TemplateBinding Content}"/>
<Path Name="SortIcon"
Grid.Column="1"
Fill="#FF444444"
HorizontalAlignment="Left"
VerticalAlignment="Center"
Stretch="Uniform"
Width="8"
Margin="4,0,0,0"
Data="F1 M -5.215,6.099L 5.215,6.099L 0,0L -5.215,6.099 Z "/>
</Grid>
<Rectangle Name="VerticalSeparator"
@ -207,6 +219,27 @@
<Setter Property="Opacity" Value="0.5"/>
</Style>
<Style Selector="dg|DataGridColumnHeader /template/ Path#SortIcon">
<Setter Property="IsVisible" Value="False"/>
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX="0.9" ScaleY="0.9" />
</Setter.Value>
</Setter>
</Style>
<Style Selector="dg|DataGridColumnHeader:sortascending /template/ Path#SortIcon">
<Setter Property="IsVisible" Value="True"/>
</Style>
<Style Selector="dg|DataGridColumnHeader:sortdescending /template/ Path#SortIcon">
<Setter Property="IsVisible" Value="True"/>
<Setter Property="RenderTransform">
<Setter.Value>
<ScaleTransform ScaleX="0.9" ScaleY="-0.9" />
</Setter.Value>
</Setter>
</Style>
<!--FIX-->
<Style Selector="dg|DataGridRow">
<Setter Property="Template">
@ -219,6 +252,7 @@
<prim:DataGridRowHeader Grid.RowSpan="3" Name="PART_RowHeader" prim:DataGridFrozenGrid.IsFrozen="True" />
<prim:DataGridCellsPresenter Grid.Column="1" Name="PART_CellsPresenter" prim:DataGridFrozenGrid.IsFrozen="True" />
<prim:DataGridDetailsPresenter Grid.Row="1" Grid.Column="1" Name="PART_DetailsPresenter"/>
<Rectangle Grid.Row="2" Grid.Column="1" Name="PART_BottomGridLine" HorizontalAlignment="Stretch" Height="1" />
</prim:DataGridFrozenGrid>
@ -468,7 +502,7 @@
<Rectangle Grid.Column="1" Grid.ColumnSpan="5" Fill="#FFFFFFFF" Height="1"/>
<Rectangle Grid.Column="1" Grid.Row="1" Name="IndentSpacer" />
<ToggleButton Grid.Column="2" Grid.Row="1" Name="ExpanderButton" Height="15" Width="15" Margin="2,0,0,0"/>
<ToggleButton Grid.Column="2" Grid.Row="1" Name="ExpanderButton" Margin="2,0,0,0"/>
<StackPanel Grid.Column="3" Grid.Row="1" Orientation="Horizontal" VerticalAlignment="Center" Margin="0,1,0,1">
<TextBlock Name="PropertyNameElement" Margin="4,0,0,0" IsVisible="{TemplateBinding IsPropertyNameVisible}"/>
@ -482,6 +516,23 @@
</ControlTemplate>
</Setter>
</Style>
<Style Selector="dg|DataGridRowGroupHeader /template/ ToggleButton#ExpanderButton">
<Setter Property="Template">
<ControlTemplate>
<Border Grid.Column="0" Width="20" Height="20" Background="Transparent" HorizontalAlignment="Center" VerticalAlignment="Center">
<Path Fill="Black"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Data="M 0 2 L 4 6 L 0 10 Z" />
</Border>
</ControlTemplate>
</Setter>
</Style>
<Style Selector="dg|DataGridRowGroupHeader /template/ ToggleButton#ExpanderButton:checked /template/ Path">
<Setter Property="RenderTransform">
<RotateTransform Angle="90" />
</Setter>
</Style>
<!--

16
src/Avalonia.DataGrid/DataGridColumnHeader.cs

@ -248,6 +248,22 @@ namespace Avalonia.Controls
}
}
*/
CurrentSortingState = null;
if (OwningGrid != null
&& OwningGrid.DataConnection != null
&& OwningGrid.DataConnection.AllowSort)
{
var sort = OwningColumn.GetSortDescription();
if(sort != null)
{
CurrentSortingState = sort.Descending ? ListSortDirection.Descending : ListSortDirection.Ascending;
}
}
PseudoClasses.Set(":sortascending",
CurrentSortingState.HasValue && CurrentSortingState.Value == ListSortDirection.Ascending);
PseudoClasses.Set(":sortdescending",
CurrentSortingState.HasValue && CurrentSortingState.Value == ListSortDirection.Descending);
}

11
src/Avalonia.DataGrid/DataGridRow.cs

@ -29,7 +29,7 @@ namespace Avalonia.Controls
private const string DATAGRIDROW_elementBottomGridLine = "PART_BottomGridLine";
private const string DATAGRIDROW_elementCells = "PART_CellsPresenter";
private const string DATAGRIDROW_elementDetails = "Part_DetailsPresenter";
private const string DATAGRIDROW_elementDetails = "PART_DetailsPresenter";
internal const string DATAGRIDROW_elementRoot = "PART_Root";
internal const string DATAGRIDROW_elementRowHeader = "PART_RowHeader";
@ -1080,11 +1080,12 @@ namespace Avalonia.Controls
_previousDetailsHeight = newValue.Height;
if (newValue.Height != oldValue && newValue.Height != _detailsDesiredHeight)
{
// Update the new desired height for RowDetails
_detailsDesiredHeight = newValue.Height;
if (AreDetailsVisible && _appliedDetailsTemplate != null)
{
// Update the new desired height for RowDetails
_detailsDesiredHeight = newValue.Height;
//if (DetailsVisibleStoryboard != null)
//{
// DetailsVisibleStoryboard.SkipToFill();
@ -1097,6 +1098,10 @@ namespace Avalonia.Controls
// to do. In certain scenarios, this could cause a layout cycle
OnRowDetailsChanged();
}
//else if(_detailsContent != null)
//{
// _detailsDesiredHeight = _detailsContent.DesiredSize.Height;
//}
}
}
else

Loading…
Cancel
Save