数据网格行在 macOS 中未正确对齐

时间:2021-02-15 16:36:08

标签: xaml xamarin xamarin.forms datagrid

使用 xamarin.forms.datagrid 控件时,我无法在 mac 中正确对齐网格行。

在下面找到我的 Xaml 代码

<dg:DataGrid ItemsSource="{Binding WorkingQueue,Mode=TwoWay}" 
    x:Name="dgWorkingQueue" SelectedItem="{Binding SelectedDataset}" 
    SelectionEnabled="True" RowHeight="50" HeaderHeight="50" 
    IsSortable="False"
    BorderColor="White" HeaderBackground="#E0E6F8" 
    HorizontalOptions="StartAndExpand" VerticalOptions="StartAndExpand" 
    ActiveRowColor="#00FFFFFF"
    HeightRequest="420" WidthRequest="992" 
    ItemSelected="dgWorkingQueue_ItemSelected" 
    IsRefreshing="{Binding IsRefreshing}">
    <dg:DataGrid.HeaderFontSize>
        <OnIdiom x:TypeArguments="x:Double">
            <OnIdiom.Tablet>15</OnIdiom.Tablet>
            <OnIdiom.Phone>12</OnIdiom.Phone>
        </OnIdiom>
    </dg:DataGrid.HeaderFontSize>
    <dg:DataGrid.NoDataView>
        <Label Text="No records to show" FontSize="18" HorizontalOptions="Center" VerticalOptions="Center" Margin="0,50,0,0" />
    </dg:DataGrid.NoDataView>
    <dg:DataGrid.Columns>
        <dg:DataGridColumn Title="Site ID" Width="*">
        <dg:DataGridColumn.CellTemplate>
            <DataTemplate>
                <Entry Text="{Binding SiteID}" FontSize="14"  IsReadOnly="True" HorizontalTextAlignment="Center"></Entry>
            </DataTemplate>
        </dg:DataGridColumn.CellTemplate>
    </dg:DataGridColumn>
    <dg:DataGridColumn Title="Dataset Name" Width="*">
        <dg:DataGridColumn.CellTemplate>
            <DataTemplate>
                <Entry Text="{Binding DatasetName}" FontSize="14" IsReadOnly="True" HorizontalTextAlignment="Center" HorizontalOptions="FillAndExpand"></Entry>
            </DataTemplate>
        </dg:DataGridColumn.CellTemplate>
    </dg:DataGridColumn>
    <dg:DataGridColumn Title="Scan Date" Width="*">
        <dg:DataGridColumn.CellTemplate>
            <DataTemplate>
                <Entry Text="{Binding ScanDate,StringFormat='{}{0:MM-dd-yyyy}'}"  FontSize="14" IsReadOnly="True"  HorizontalTextAlignment="Center"></Entry>
            </DataTemplate>
        </dg:DataGridColumn.CellTemplate>
    </dg:DataGridColumn>
    <dg:DataGridColumn Title="Asset Owner" Width="*">
        <dg:DataGridColumn.CellTemplate>
            <DataTemplate>
                <Entry Text="{Binding AssetOwner}" FontSize="14" IsReadOnly="True"  HorizontalTextAlignment="Center"></Entry>
            </DataTemplate>
        </dg:DataGridColumn.CellTemplate>
    </dg:DataGridColumn>
    <dg:DataGridColumn Title="Project Name" Width="*">
        <dg:DataGridColumn.CellTemplate>
            <DataTemplate>
                 <Entry Text="{Binding ProjectName}" FontSize="14" IsReadOnly="True"  HorizontalTextAlignment="Center"></Entry>
            </DataTemplate>
        </dg:DataGridColumn.CellTemplate>
    </dg:DataGridColumn>
                                                    <dg:DataGridColumn Title="Action" Width="*">
                                                    <dg:DataGridColumn.CellTemplate >
                                                        <DataTemplate>
                                                            <ContentView>
                                                                <StackLayout Orientation="Horizontal" HorizontalOptions="Center">
                                                                    <Button Text="View" Style="{StaticResource RoundedButton}" FontFamily="{StaticResource FontTypeAwesomeSolid}" Command="{Binding Path= BindingContext.ViewDatasetCommand, Source={x:Reference dgWorkingQueue}}" CommandParameter="{Binding DatasetID}" />
                                                                    <Button Text="Move" Style="{StaticResource RoundedButton}" FontFamily="{StaticResource FontTypeAwesomeSolid}" Command="{Binding Path= BindingContext.MoveToUploadQueueCommand, Source={x:Reference dgWorkingQueue}}" CommandParameter="{Binding DatasetID}" />
                                                                </StackLayout>
                                                            </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>

截图

enter image description here

0 个答案:

没有答案
相关问题