Browse Source
Merge branch 'master' into fixes/Dependencies
pull/5202/head
Max Katz
5 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with
18 additions and
4 deletions
-
samples/ControlCatalog/Pages/DataGridPage.xaml
-
src/Avalonia.Controls.DataGrid/DataGrid.cs
|
|
|
@ -38,8 +38,8 @@ |
|
|
|
<DataGrid.Columns> |
|
|
|
<DataGridTextColumn Header="Country" Binding="{Binding Name}" Width="6*" /> |
|
|
|
<DataGridTextColumn Header="Region" Binding="{Binding Region}" Width="4*" /> |
|
|
|
<DataGridTextColumn Header="Population" Binding="{Binding Population}" Width="3*" /> |
|
|
|
<DataGridTextColumn Header="Area" Binding="{Binding Area}" Width="3*" /> |
|
|
|
<DataGridTextColumn DisplayIndex="3" Header="Population" Binding="{Binding Population}" Width="3*" /> |
|
|
|
<DataGridTextColumn DisplayIndex="2" Header="Area" Binding="{Binding Area}" Width="3*" /> |
|
|
|
<DataGridTextColumn Header="GDP" Binding="{Binding GDP}" Width="3*" /> |
|
|
|
</DataGrid.Columns> |
|
|
|
</DataGrid> |
|
|
|
|
|
|
|
@ -2285,6 +2285,17 @@ namespace Avalonia.Controls |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Comparator class so we can sort list by the display index
|
|
|
|
/// </summary>
|
|
|
|
public class DisplayIndexComparer : IComparer<DataGridColumn> |
|
|
|
{ |
|
|
|
int IComparer<DataGridColumn>.Compare(DataGridColumn x, DataGridColumn y) |
|
|
|
{ |
|
|
|
return (x.DisplayIndexWithFiller < y.DisplayIndexWithFiller) ? -1 : 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Builds the visual tree for the column header when a new template is applied.
|
|
|
|
/// </summary>
|
|
|
|
@ -2309,8 +2320,11 @@ namespace Avalonia.Controls |
|
|
|
ColumnsInternal.FillerColumn.IsRepresented = false; |
|
|
|
} |
|
|
|
_columnHeadersPresenter.OwningGrid = this; |
|
|
|
// Columns were added before before our Template was applied, add the ColumnHeaders now
|
|
|
|
foreach (DataGridColumn column in ColumnsItemsInternal) |
|
|
|
|
|
|
|
// Columns were added before our Template was applied, add the ColumnHeaders now
|
|
|
|
List<DataGridColumn> sortedInternal = new List<DataGridColumn>(ColumnsItemsInternal); |
|
|
|
sortedInternal.Sort(new DisplayIndexComparer()); |
|
|
|
foreach (DataGridColumn column in sortedInternal) |
|
|
|
{ |
|
|
|
InsertDisplayedColumnHeader(column); |
|
|
|
} |
|
|
|
|