Skip to content

Commit

Permalink
add PullToRefreshCommandParameter and RefreshColor
Browse files Browse the repository at this point in the history
  • Loading branch information
Edward Miller committed Jan 16, 2024
1 parent fcdc408 commit 4cb4b06
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Maui.DataGrid.Sample/SettingsPopup.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<Label Text="Pagination Enabled?" TextColor="White" VerticalOptions="Center" />
</HorizontalStackLayout>
<HorizontalStackLayout Style="{StaticResource SampleContainerStyle}">
<Picker SelectedItem="{Binding SelectionMode}" ItemsSource="{Binding SelectionModes}" />
<Picker SelectedItem="{Binding SelectionMode}" ItemsSource="{Binding SelectionModes}" ItemDisplayBinding="{Binding .}" />
<Label Text="Selection Mode" TextColor="White" VerticalOptions="Center" />
</HorizontalStackLayout>
<HorizontalStackLayout Style="{StaticResource SampleContainerStyle}">
Expand Down
4 changes: 2 additions & 2 deletions Maui.DataGrid/DataGrid.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid Grid.Row="0" x:Name="_headerView" HeightRequest="{Binding HeaderHeight, Source={Reference self}}" />
<RefreshView Grid.Row="1" x:Name="_refreshView" Grid.RowSpan="2" Command="{Binding PullToRefreshCommand, Source={Reference self}}"
IsRefreshing="{Binding IsRefreshing, Source={Reference self}, Mode=TwoWay}" IsEnabled="{Binding RefreshingEnabled, Source={Reference self}}">
<RefreshView Grid.Row="1" x:Name="_refreshView" Grid.RowSpan="2" Command="{Binding PullToRefreshCommand, Source={Reference self}}" CommandParameter="{Binding PullToRefreshCommandParameter, Source={Reference self}}"
RefreshColor="{Binding RefreshColor, Source={Reference self}}" IsRefreshing="{Binding IsRefreshing, Source={Reference self}, Mode=TwoWay}" IsEnabled="{Binding RefreshingEnabled, Source={Reference self}}">
<!-- Set all platforms to use MeasureFirstItem when this bug is resolved https://github.com/dotnet/maui/issues/7562 -->
<CollectionView
x:Name="_collectionView"
Expand Down
24 changes: 24 additions & 0 deletions Maui.DataGrid/DataGrid.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,18 @@ private void SortAndPaginate(SortData? sortData = null)
}
});

/// <summary>
/// Gets or sets the parameter to pass to the <see cref="PullToRefreshCommand"/>
/// </summary>
public static readonly BindableProperty PullToRefreshCommandParameterProperty =
BindablePropertyExtensions.Create<DataGrid, object>();

/// <summary>
/// Gets or sets the spinner color to use while refreshing.
/// </summary>
public static readonly BindableProperty RefreshColorProperty =
BindablePropertyExtensions.Create<DataGrid, Color>(Colors.Purple);

/// <summary>
/// Gets or sets a value indicating whether the DataGrid is refreshing.
/// </summary>
Expand Down Expand Up @@ -1031,6 +1043,18 @@ public ICommand PullToRefreshCommand
set => SetValue(PullToRefreshCommandProperty, value);
}

public object PullToRefreshCommandParameter
{
get => GetValue(PullToRefreshCommandParameterProperty);
set => SetValue(PullToRefreshCommandParameterProperty, value);
}

public Color RefreshColor
{
get => (Color)GetValue(RefreshColorProperty);
set => SetValue(RefreshColorProperty, value);
}

/// <summary>
/// Displays an ActivityIndicator when is refreshing
/// </summary>
Expand Down

0 comments on commit 4cb4b06

Please sign in to comment.