Ширина столбца форм Xamarin не заполняет всю ячейку - PullRequest
0 голосов
/ 02 мая 2019

У меня есть сетка с 4 столбцами.Столбцы 1, 2, 4 являются абсолютными.И я хочу, чтобы колонка 3 заполнила пространство.У меня проблема в том, что некоторые данные столбца 3 не заполняют все пространство, а столбец 4 не выровнен. Строки 1 и 4 показывают проблему.

Вот мой код (новичок, пытающийся получить представление о визуальной части XAML).

<ListView x:Name="lstData" HasUnevenRows="True" VerticalOptions="StartAndExpand" HorizontalOptions="FillAndExpand">
    <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
                <Grid Padding="0, 5, 0, 5" HorizontalOptions="StartAndExpand" VerticalOptions="StartAndExpand">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="45"></ColumnDefinition>
                        <ColumnDefinition Width="20"></ColumnDefinition>
                        <ColumnDefinition Width="*"></ColumnDefinition>
                        <ColumnDefinition Width="20"></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"></RowDefinition>
                        <RowDefinition Height="Auto"></RowDefinition>
                    </Grid.RowDefinitions>

                    <Label Text="{Binding TimesheetDate}" Grid.Row="0" Grid.Column="0" HorizontalOptions="StartAndExpand" FontSize="Micro"></Label>
                    <Label Text="{Binding UserInitials}" Grid.Row="0" Grid.Column="1" HorizontalOptions="StartAndExpand" FontSize="Micro"></Label>
                    <Label Text="{Binding TaskSummary}" Grid.Row="0" Grid.Column="2" HorizontalOptions="FillAndExpand" LineBreakMode="WordWrap" FontSize="Micro"></Label>
                    <Label Text="{Binding TimesheetHours, StringFormat='{}{0:f2}'}" Grid.Row="0" Grid.Column="3" HorizontalOptions="EndAndExpand" FontSize="Micro"></Label>

                    <Label Text="{Binding TaskID}" Grid.Row="1" Grid.Column="0" VerticalOptions="Center" HorizontalOptions="CenterAndExpand" FontSize="Micro"></Label>
                    <Label Text="" Grid.Row="1" Grid.Column="1" FontSize="Micro" HorizontalOptions="CenterAndExpand"></Label>
                    <Label Text="{Binding UserComments}" Grid.Row="1" Grid.Column="2" LineBreakMode="WordWrap" HorizontalOptions="FillAndExpand" FontSize="Micro"></Label>
                    <Label Text="" Grid.Row="1" Grid.Column="3" FontSize="Micro" HorizontalOptions="EndAndExpand"></Label>
                </Grid>
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

Спасибозаранее, Крис

1 Ответ

2 голосов
/ 02 мая 2019

вы можете изменить HorizontalOptions вашего Grid,

изменить

<Grid Padding="0, 5, 0, 5" HorizontalOptions="StartAndExpand" VerticalOptions="StartAndExpand">

до:

 <Grid Padding="0, 5, 0, 5" HorizontalOptions="FillAndExpand" VerticalOptions="StartAndExpand">
...