我有一个带有标签的Listview。如果我再向下滚动,Label会有其他高度和宽度。甚至一些标签似乎保持稳定。
有谁知道如何解决这个问题,所以所有标签保持原始尺寸?
列表显示:
<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>
ColumnDefinition:
<ColumnDefinitionCollection x:Key="ColumnDefinition">
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="Auto"/>
</ColumnDefinitionCollection>
对于ColumnDefinitions
,使用*
而不是Auto
来避免动态调整大小。
<ColumnDefinitionCollection x:Key="ColumnDefinition">
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</ColumnDefinitionCollection>