滚动后Listview中的标签更改高度和宽度

时间:2019-04-24 16:22:26

标签: listview xamarin.forms xamarin.android xamarin.ios

我有一个带有标签的Listview。如果我再次上下滚动,标签将具有其他高度和宽度。甚至某些标签似乎都保持稳定。

有人知道如何解决此问题,以便所有标签都保持其原始大小吗?

ListView:

01-17-11-

ColumnDefinition:

<ListView
    HasUnevenRows="True"
    SeparatorVisibility="None"
    CachingStrategy="RecycleElement"
    ItemsSource="{Binding Contacts}">
    <ListView.Behaviors>
        <b:EventToCommandBehavior
            EventName="ItemTapped"
            Command="{Binding ContactTappedCommand}"
            EventArgsParameterPath="Item"/>
    </ListView.Behaviors>
    <ListView.ItemTemplate>
        <DataTemplate>
            <ViewCell>
                <Frame
                    Style="{StaticResource ListViewEintrag}">
                    <Grid 
                        Style="{StaticResource ListViewGrid}"
                        RowDefinitions="{StaticResource RowDefinition}"
                        ColumnDefinitions="{StaticResource ColumnDefinition}">
                        <local:CustomLabel
                            Grid.Row="0"
                            Grid.Column="0"
                            LetterSpacing="0.15"
                            Style="{StaticResource Name}"
                            Text="{Binding Name}"/>
                        <local:CustomLabel
                            Grid.Row="1"
                            Grid.Column="0"
                            TextColor="#33A028"
                            Style="{StaticResource Info}"
                            Text="{Binding TotalCredits, Converter={StaticResource DecimalToCurrency}}"/>
                        <local:CustomLabel
                            Grid.Row="2"
                            Grid.Column="0"
                            TextColor="#BC2F36"
                            Style="{StaticResource Info}"
                            Text="{Binding TotalDebts, Converter={StaticResource DecimalToCurrency}}"/>
                        <local:CustomLabel
                            LetterSpacing="0.1"
                            Grid.RowSpan="3"
                            Grid.Column="1"
                            FontSize="18"
                            Margin="10,0"
                            FontFamily="{StaticResource Bliss2-Bold}"
                            VerticalTextAlignment="Center"
                            HorizontalTextAlignment="End"
                            TextColor="{Binding Color}"
                            Text="{Binding AbsSaldo, Converter={StaticResource DecimalToCurrency}}"/>
                    </Grid>
                </Frame>
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

Screenshot

1 个答案:

答案 0 :(得分:0)

对于ColumnDefinitions,请使用*而不是Auto,以避免动态调整大小。

<ColumnDefinitionCollection x:Key="ColumnDefinition">
    <ColumnDefinition Width="*"/>
    <ColumnDefinition Width="*"/>
</ColumnDefinitionCollection>