Skip to content

Commit

Permalink
Make layout sensible
Browse files Browse the repository at this point in the history
  • Loading branch information
Edward Miller committed Jan 17, 2024
1 parent 4cb4b06 commit b7a6f1e
Show file tree
Hide file tree
Showing 11 changed files with 342 additions and 109 deletions.
5 changes: 3 additions & 2 deletions Maui.DataGrid.Sample/MainPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@
</Grid>

<dg:DataGrid Grid.Row="1" ItemsSource="{Binding Teams}" SelectionMode="{Binding SelectionMode}" SelectedItem="{Binding SelectedTeam}"
RowHeight="70" HeaderHeight="50" BorderColor="{StaticResource GridBorderColor}" RowToEdit="{Binding TeamToEdit}"
BorderColor="{StaticResource GridBorderColor}" BorderThickness="{Binding BorderThickness}" RowToEdit="{Binding TeamToEdit}"
HeaderBackground="{StaticResource GridHeaderBgColor}" HeaderBordersVisible="{Binding HeaderBordersVisible}"
PullToRefreshCommand="{Binding Commands[Refresh]}" IsRefreshing="{Binding IsRefreshing}"
PaginationEnabled="{Binding PaginationEnabled}" PageSize="{Binding PageSize}"
ActiveRowColor="{StaticResource ActiveRowColor}" FooterBackground="{StaticResource GridFooterBgColor}" x:Name="_dataGrid1">
ActiveRowColor="{StaticResource ActiveRowColor}" FooterBackground="{StaticResource GridFooterBgColor}"
RowHeight="70" HeaderHeight="50" x:Name="_dataGrid1">
<dg:DataGrid.Columns>
<dg:DataGridColumn Title="Logo" PropertyName="Logo" SortingEnabled="False">
<dg:DataGridColumn.CellTemplate>
Expand Down
1 change: 1 addition & 0 deletions Maui.DataGrid.Sample/Resources/Styles/Colors.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@
<Color x:Key="GridHeaderBgColor">#E0E6F8</Color>
<Color x:Key="GridFooterBgColor">#E0E6F8</Color>
<Color x:Key="GridBorderColor">#CCCCCC</Color>
<Color x:Key="GridBgColor">#CCCCCC</Color>
</ResourceDictionary>
5 changes: 5 additions & 0 deletions Maui.DataGrid.Sample/SettingsPopup.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
<CheckBox IsChecked="{Binding HeaderBordersVisible}" />
<Label Text="Header Borders Visible?" TextColor="White" VerticalOptions="Center" />
</HorizontalStackLayout>
<HorizontalStackLayout Style="{StaticResource SampleContainerStyle}">
<Stepper Minimum="0" Maximum="10" Value="{Binding BorderThicknessNumeric}"
BackgroundColor="{OnPlatform WinUI=Gray}"/>
<Label Text="Border Thickness" TextColor="White" VerticalOptions="Center" />
</HorizontalStackLayout>
<HorizontalStackLayout Style="{StaticResource SampleContainerStyle}">
<CheckBox IsChecked="{Binding WonColumnVisible}" />
<Label Text="Won Column" TextColor="White" VerticalOptions="Center" />
Expand Down
15 changes: 15 additions & 0 deletions Maui.DataGrid.Sample/ViewModels/MainViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public MainViewModel()
TeamColumnWidth = 70;
SelectionMode = SelectionMode.Single;
PageSize = 6;
BorderThicknessNumeric = 1;

Commands.Add("CompleteEdit", new Command(CmdCompleteEdit));
Commands.Add("Edit", new Command<Team>(CmdEdit));
Expand Down Expand Up @@ -56,6 +57,20 @@ public bool WonColumnVisible
set => SetValue(value);
}

public double BorderThicknessNumeric
{
get => GetValue<double>();
set
{
if (SetValue(value))
{
OnPropertyChanged(nameof(BorderThickness));
}
}
}

public Thickness BorderThickness => new(BorderThicknessNumeric);

public ushort TeamColumnWidth
{
get => GetValue<ushort>();
Expand Down
6 changes: 4 additions & 2 deletions Maui.DataGrid.Sample/ViewModels/ViewModelBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,17 @@ protected ViewModelBase()
Commands = [];
}

protected void SetValue(object value, [CallerMemberName] string propertyName = null)
protected bool SetValue(object value, [CallerMemberName] string propertyName = null)
{
if (_properties.TryGetValue(propertyName!, out var item) && item == value)
{
return;
return false;
}

_properties[propertyName!] = value;
OnPropertyChanged(propertyName);

return true;
}

protected T GetValue<T>([CallerMemberName] string propertyName = null)
Expand Down
98 changes: 98 additions & 0 deletions Maui.DataGrid/CompatibilitySuppressions.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- https://learn.microsoft.com/en-us/dotnet/fundamentals/package-validation/diagnostic-ids -->
<Suppressions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Maui.DataGrid.DataGridCell</Target>
<Left>lib/net7.0/Maui.DataGrid.dll</Left>
<Right>lib/net7.0/Maui.DataGrid.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0001</DiagnosticId>
<Target>T:Maui.DataGrid.DataGridCell</Target>
<Left>lib/net8.0/Maui.DataGrid.dll</Left>
<Right>lib/net8.0/Maui.DataGrid.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>F:Maui.DataGrid.DataGrid.PullToRefreshCommandParameterProperty</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.RefreshColorProperty</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.SelectedItemsProperty</Target>
Expand All @@ -15,6 +43,20 @@
<Right>lib/net7.0/Maui.DataGrid.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Maui.DataGrid.DataGrid.get_PullToRefreshCommandParameter</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_RefreshColor</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_SelectedItems</Target>
Expand All @@ -36,6 +78,20 @@
<Right>lib/net7.0/Maui.DataGrid.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Maui.DataGrid.DataGrid.set_PullToRefreshCommandParameter(System.Object)</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_RefreshColor(Microsoft.Maui.Graphics.Color)</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_SelectedItems(System.Collections.ObjectModel.ObservableCollection{System.Object})</Target>
Expand All @@ -57,6 +113,20 @@
<Right>lib/net7.0/Maui.DataGrid.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>F:Maui.DataGrid.DataGrid.PullToRefreshCommandParameterProperty</Target>
<Left>lib/net8.0/Maui.DataGrid.dll</Left>
<Right>lib/net8.0/Maui.DataGrid.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>F:Maui.DataGrid.DataGrid.RefreshColorProperty</Target>
<Left>lib/net8.0/Maui.DataGrid.dll</Left>
<Right>lib/net8.0/Maui.DataGrid.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>F:Maui.DataGrid.DataGrid.SelectedItemsProperty</Target>
Expand All @@ -71,6 +141,20 @@
<Right>lib/net8.0/Maui.DataGrid.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Maui.DataGrid.DataGrid.get_PullToRefreshCommandParameter</Target>
<Left>lib/net8.0/Maui.DataGrid.dll</Left>
<Right>lib/net8.0/Maui.DataGrid.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Maui.DataGrid.DataGrid.get_RefreshColor</Target>
<Left>lib/net8.0/Maui.DataGrid.dll</Left>
<Right>lib/net8.0/Maui.DataGrid.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Maui.DataGrid.DataGrid.get_SelectedItems</Target>
Expand All @@ -92,6 +176,20 @@
<Right>lib/net8.0/Maui.DataGrid.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Maui.DataGrid.DataGrid.set_PullToRefreshCommandParameter(System.Object)</Target>
<Left>lib/net8.0/Maui.DataGrid.dll</Left>
<Right>lib/net8.0/Maui.DataGrid.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Maui.DataGrid.DataGrid.set_RefreshColor(Microsoft.Maui.Graphics.Color)</Target>
<Left>lib/net8.0/Maui.DataGrid.dll</Left>
<Right>lib/net8.0/Maui.DataGrid.dll</Right>
<IsBaselineSuppression>true</IsBaselineSuppression>
</Suppression>
<Suppression>
<DiagnosticId>CP0002</DiagnosticId>
<Target>M:Maui.DataGrid.DataGrid.set_SelectedItems(System.Collections.ObjectModel.ObservableCollection{System.Object})</Target>
Expand Down
2 changes: 1 addition & 1 deletion Maui.DataGrid/DataGrid.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<CollectionView
x:Name="_collectionView"
WidthRequest="{Binding WidthRequest, Source={Reference self}}"
BackgroundColor="{Binding BorderColor, Source={Reference self}}"
BackgroundColor="{Binding BackgroundColor, Source={Reference self}}"
SelectedItem="{Binding SelectedItem, Source={Reference self}, Mode=TwoWay}"
SelectedItems="{Binding SelectedItems, Source={Reference self}, Mode=TwoWay}"
ItemSizingStrategy="{Binding ItemSizingStrategy, Source={Reference self}}"
Expand Down
Loading

0 comments on commit b7a6f1e

Please sign in to comment.