https://github.com/akgulebubekir/Maui.DataGrid


 xmlns:dg="clr-namespace:Maui.DataGrid;assembly=Maui.DataGrid"
<dg:DataGrid ItemsSource="{Binding Teams}" SelectionEnabled="True" SelectedItem="{Binding SelectedTeam}"
             RowHeight="70" HeaderHeight="50" BorderColor="{StaticResource GridBorderColor}"
             HeaderBackground="{StaticResource GridHeaderBgColor}"
             PullToRefreshCommand="{Binding RefreshCommand}" IsRefreshing="{Binding IsRefreshing}"
             ActiveRowColor="{StaticResource ActiveRowColor}">
    <dg:DataGrid.Columns>
        <dg:DataGridColumn Title="Logo" PropertyName="Logo" Width="150" SortingEnabled="False">
            <dg:DataGridColumn.CellTemplate>
                <DataTemplate>
                    <Image Source="{Binding}" HorizontalOptions="Center" VerticalOptions="Center"
                           Aspect="AspectFit" HeightRequest="60" ></Image>
                </DataTemplate>
            </dg:DataGridColumn.CellTemplate>
        </dg:DataGridColumn>
        <dg:DataGridColumn Title="Team" PropertyName="Name" ></dg:DataGridColumn>
        <dg:DataGridColumn Title="Won" PropertyName="Won" ></dg:DataGridColumn>
        <dg:DataGridColumn Title="Lost" PropertyName="Lost" ></dg:DataGridColumn>
        <dg:DataGridColumn PropertyName="Home">
            <dg:DataGridColumn.FormattedTitle>
                <FormattedString>
                    <Span Text="Home" TextColor="Black" FontSize="13" FontAttributes="Bold" ></Span>
                    <Span Text=" (win-loose)" TextColor="#333333" FontSize="11" ></Span>
                </FormattedString>
            </dg:DataGridColumn.FormattedTitle>
        </dg:DataGridColumn>
        <dg:DataGridColumn Title="Percentage" PropertyName="Percentage" StringFormat="{}{0:0.00}" ></dg:DataGridColumn>
        <dg:DataGridColumn Title="Streak" PropertyName="Streak" Width="0.5*">
            <dg:DataGridColumn.CellTemplate>
                <DataTemplate>
                    <ContentView HorizontalOptions="Fill" VerticalOptions="Fill"
                                 BackgroundColor="{Binding Converter={StaticResource StreakToColorConverter}}">
                        <Label Text="{Binding}" HorizontalOptions="Center" VerticalOptions="Center"
                               TextColor="Black" ></Label>
                    </ContentView>
                </DataTemplate>
            </dg:DataGridColumn.CellTemplate>
        </dg:DataGridColumn>
    </dg:DataGrid.Columns>
    <dg:DataGrid.RowsBackgroundColorPalette>
        <dg:PaletteCollection>
            <Color>#F2F2F2</Color>
            <Color>#FFFFFF</Color>
        </dg:PaletteCollection>
    </dg:DataGrid.RowsBackgroundColorPalette>
    <dg:DataGrid.Resources>
        <ResourceDictionary>
            <conv:StreakToColorConverter x:Key="StreakToColorConverter" ></conv:StreakToColorConverter>
        </ResourceDictionary>
    </dg:DataGrid.Resources>
</dg:DataGrid>
文档更新时间: 2023-06-13 13:49   作者:admin