Skip to content

Commit

Permalink
Expose PaginationStepperStyle as BindableProperty
Browse files Browse the repository at this point in the history
  • Loading branch information
Edward Miller committed Dec 29, 2023
1 parent 3b98784 commit 9a1ba5b
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 17 deletions.
21 changes: 21 additions & 0 deletions Maui.DataGrid/CompatibilitySuppressions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
<Right>lib/net7.0/Maui.DataGrid.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>F:Maui.DataGrid.DataGrid.PaginationStepperStyleProperty</Target>
<Left>lib/net7.0/Maui.DataGrid.dll</Left>
<Right>lib/net7.0/Maui.DataGrid.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>F:Maui.DataGrid.DataGrid.RowToEditProperty</Target>
Expand All @@ -29,6 +36,13 @@
<Right>lib/net7.0/Maui.DataGrid.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Maui.DataGrid.DataGrid.get_PaginationStepperStyle</Target>
<Left>lib/net7.0/Maui.DataGrid.dll</Left>
<Right>lib/net7.0/Maui.DataGrid.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Maui.DataGrid.DataGrid.get_RowToEdit</Target>
Expand All @@ -43,6 +57,13 @@
<Right>lib/net7.0/Maui.DataGrid.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Maui.DataGrid.DataGrid.set_PaginationStepperStyle(Microsoft.Maui.Controls.Style)</Target>
<Left>lib/net7.0/Maui.DataGrid.dll</Left>
<Right>lib/net7.0/Maui.DataGrid.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Maui.DataGrid.DataGrid.set_RowToEdit(System.Object)</Target>
Expand Down
8 changes: 5 additions & 3 deletions Maui.DataGrid/DataGrid.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,11 @@
<Setter Property="Points" Value="50,0 0,80 100,80" />
<Setter Property="Margin" Value="0,0,3,0" />
</Style>
<!--Pagination Stepper Style-->
<Style x:Key="PaginationStepperStyle" TargetType="Stepper">
<!--Default Pagination Stepper Style-->
<Style x:Key="DefaultPaginationStepperStyle" TargetType="Stepper">
<Setter Property="Margin" Value="5" />
<Setter Property="VerticalOptions" Value="Center" />
<Setter Property="BackgroundColor" Value="{OnPlatform WinUI=Black}" />
</Style>
</ResourceDictionary>
</ContentView.Resources>
Expand Down Expand Up @@ -70,7 +72,7 @@
<HorizontalStackLayout Grid.Column="2" VerticalOptions="Center">
<Label Text="Page:" Margin="0,0,5,0" VerticalTextAlignment="Center" TextColor="Black" />
<Label Text="{Binding PageNumber, Source={Reference self}}" VerticalTextAlignment="Center" TextColor="Black" />
<Stepper x:Name="_paginationStepper" Value="{Binding PageNumber, Source={Reference self}}" Style="{StaticResource PaginationStepperStyle}" Minimum="1" />
<Stepper x:Name="_paginationStepper" Value="{Binding PageNumber, Source={Reference self}}" Style="{Binding PaginationStepperStyle, Source={Reference self}}" Minimum="1" />
</HorizontalStackLayout>
</Grid>
</Grid>
Expand Down
44 changes: 30 additions & 14 deletions Maui.DataGrid/DataGrid.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,20 @@ private void SortAndPaginate(SortData? sortData = null)
}
});

/// <summary>
/// Gets or sets a value indicating whether pagination is enabled in the DataGrid.
/// </summary>
public static readonly BindableProperty PaginationEnabledProperty =
BindablePropertyExtensions.Create<DataGrid, bool>(false,
propertyChanged: (b, o, n) =>
{
if (o != n)
{
var self = (DataGrid)b;
self.SortAndPaginate();
}
});

/// <summary>
/// Gets or sets the ItemsSource for the DataGrid.
/// </summary>
Expand Down Expand Up @@ -483,6 +497,12 @@ private void SortAndPaginate(SortData? sortData = null)
public static readonly BindableProperty PageSizeVisibleProperty =
BindablePropertyExtensions.Create<DataGrid, bool>(true);

/// <summary>
/// Gets or sets the list of available page sizes for the DataGrid.
/// </summary>
public static readonly BindableProperty PaginationStepperStyleProperty =
BindablePropertyExtensions.Create<DataGrid, Style>(defaultValueCreator: x => x?.Resources["DefaultPaginationStepperStyle"] as Style);

/// <summary>
/// Gets or sets the row height for the DataGrid.
/// </summary>
Expand Down Expand Up @@ -519,6 +539,7 @@ private void SortAndPaginate(SortData? sortData = null)
public static readonly BindableProperty FontFamilyProperty =
BindablePropertyExtensions.Create<DataGrid, string>(Font.Default.Family);


/// <summary>
/// Gets or sets the selected item in the DataGrid.
/// </summary>
Expand Down Expand Up @@ -553,20 +574,6 @@ private void SortAndPaginate(SortData? sortData = null)
}
);

/// <summary>
/// Gets or sets a value indicating whether pagination is enabled in the DataGrid.
/// </summary>
public static readonly BindableProperty PaginationEnabledProperty =
BindablePropertyExtensions.Create<DataGrid, bool>(false,
propertyChanged: (b, o, n) =>
{
if (o != n)
{
var self = (DataGrid)b;
self.SortAndPaginate();
}
});

/// <summary>
/// Gets or sets a value indicating whether selection is enabled in the DataGrid.
/// </summary>
Expand Down Expand Up @@ -896,6 +903,15 @@ public bool PageSizeVisible
set => SetValue(PageSizeVisibleProperty, value);
}

/// <summary>
/// Gets or sets the pagination stepper style
/// </summary>
public Style? PaginationStepperStyle
{
get => (Style?)GetValue(PaginationStepperStyleProperty);
set => SetValue(PaginationStepperStyleProperty, value);
}

/// <summary>
/// Sets the row height
/// </summary>
Expand Down

0 comments on commit 9a1ba5b

Please sign in to comment.