0
我有列表視圖中有34個項目,它工作正常,如果我把20個項目,但是當我把所有的項目和scrolldown,列表視圖發回我向上和白色的矩形顯示在項目的地方有時會出現。它覺得渲染需要時間。我們可以把多少物品放在winrt listview中
上下滾動幾次後,表現良好。
我使用可觀察列表作爲數據源。我只想要將多少項目添加到列表視圖中,如果我們只能添加20個項目,那麼提供任何教程鏈接以添加20個以上的元素。
詩篇。我已經嘗試從互聯網的教程中進行延遲加載,但同樣的情況發生了。
編輯
<Grid Grid.Row="2" x:Name="ContentRoot">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<ListView Margin="0 20 0 10" Name="violationListView" ItemsSource="{Binding ViolationList, Mode=TwoWay}" ItemContainerStyle="{StaticResource ListViewItemExpanded1}">
<ListView.ItemTemplate>
<DataTemplate>
<!--<StackPanel Margin="16 20 16 10" Orientation="Vertical">-->
<Border Margin="8 0 8 0" Style="{StaticResource BackgroundLightStyle}" >
<Grid >
<Grid.Resources>
<common:AmountStringConversion x:Key="FormatConverter" />
<common:ZeroToEmptyStringConverter x:Key="ZeroConverter" />
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Margin="8,0,0,10" Tapped="StackPanel_Tapped" HorizontalAlignment="Stretch" Orientation="Horizontal">
<Image Source="/Assets/Images/bullet.png" VerticalAlignment="Center" Width="20" ></Image>
<TextBlock Margin="10,03,0,0" VerticalAlignment="Center" HorizontalAlignment="Stretch" Style="{StaticResource TextBoxHeadingStyle}" Text="{Binding TicketNumber, Converter={StaticResource FormatConverter}, ConverterParameter='Ticket Number {0}'}"></TextBlock>
</StackPanel>
<!--<Border Grid.Row="0" Margin="8,0,0,10" Tapped="StackPanel_Tapped" HorizontalAlignment="Stretch" Background="Transparent" />-->
<StackPanel Grid.Row="1" Margin="16 10 0 10" Orientation="Vertical" Visibility="{Binding DetailsVisibility, Mode=TwoWay}">
<TextBlock Style="{StaticResource ApplicationSubHeadingTextBlockStyle}" Text="" x:Uid="ViolationCreationDateTextBlock" />
<TextBlock Style="{StaticResource ApplicationSubHeadingContentTextBlockStyle}" Text="{Binding CreationDate}" />
<TextBlock Style="{StaticResource ApplicationSubHeadingTextBlockStyle}" x:Uid="ViolationAcceptanceTextBlock" />
<TextBlock Style="{StaticResource ApplicationSubHeadingContentTextBlockStyle}" Text="{Binding AcceptanceDate}" />
<TextBlock Style="{StaticResource ApplicationSubHeadingTextBlockStyle}" x:Uid="TripDateTimeTextBlock" />
<TextBlock Style="{StaticResource ApplicationSubHeadingContentTextBlockStyle}" Text="{Binding ViolationDate}" />
<TextBlock Style="{StaticResource ApplicationSubHeadingTextBlockStyle}" x:Uid="TollGateLocationTextBlock" />
<TextBlock Style="{StaticResource ApplicationSubHeadingContentTextBlockStyle}" Text="{Binding Gate}"/>
<TextBlock Style="{StaticResource ApplicationSubHeadingTextBlockStyle}" x:Uid="TollGateDirectionTextBlock" />
<TextBlock Style="{StaticResource ApplicationSubHeadingContentTextBlockStyle}" Text="{Binding Direction}"/>
<TextBlock Style="{StaticResource ApplicationSubHeadingTextBlockStyle}" x:Uid="AmountVoilationTextBox" />
<TextBlock Style="{StaticResource ApplicationSubHeadingContentTextBlockStyle}" Text="{Binding Amount}" />
<TextBlock Style="{StaticResource ApplicationSubHeadingTextBlockStyle}" x:Uid="ViolationStatusTextBlock" />
<TextBlock Style="{StaticResource ApplicationSubHeadingContentTextBlockStyle}" Text="{Binding ViolationStatus}" />
<TextBlock Style="{StaticResource ApplicationSubHeadingTextBlockStyle}" x:Uid="DueDateVoilationTextBlock" />
<TextBlock Style="{StaticResource ApplicationSubHeadingContentTextBlockStyle}" Text="{Binding DisputeDate}" />
<TextBlock Style="{StaticResource ApplicationSubHeadingTextBlockStyle}" x:Uid="DisputeNumberTextBlock" />
<TextBlock Style="{StaticResource ApplicationSubHeadingContentTextBlockStyle}" Text="{Binding DisputeAppNumber, Converter={StaticResource ZeroConverter}, ConverterParameter='Ticket Number {0}'}" />
<TextBlock Style="{StaticResource ApplicationSubHeadingTextBlockStyle}" x:Uid="PreffuredRefundMethodTextBlock" />
<TextBlock Style="{StaticResource ApplicationSubHeadingContentTextBlockStyle}" Text="{Binding PreferredRefundMethod}" />
<TextBlock Style="{StaticResource ApplicationSubHeadingTextBlockStyle}" x:Uid="VehicleImageTextBlock" Visibility="{Binding IsImageAvailable}" />
<StackPanel Margin="0,05,0,10" Orientation="Horizontal" Visibility="{Binding IsImageAvailable}" >
<!--<Image Width="25" VerticalAlignment="Center" Height="Auto" Source="/Assets/Images/appbar.image.hdr.png" Tapped="Tap_ViewImage"/>-->
<toolkit:ImageButton Width="25" VerticalAlignment="Center" Stretch="Fill" NormalStateImageSource="/Assets/Images/appbar.image.hdr.png" GenerateMissingImages="True" Click="Tap_ViewImage" />
<TextBlock x:Uid="VehicleImageTextBlock" Margin="10,0,0,0" Style="{StaticResource ApplicationSubHeadingContentTextBlockStyle}" VerticalAlignment="Center" Tapped="Tap_ViewImage" />
</StackPanel>
<TextBlock Style="{StaticResource ApplicationSubHeadingTextBlockStyle}" x:Uid="AddToDisputeTextBlock" />
<ToggleSwitch Name="TagActivationAgreeToggle" x:Uid="TagActivationAgreeToggle" IsEnabled="{Binding AllowDispute}" IsOn="{Binding AddToDispute , Mode=TwoWay}" />
</StackPanel>
</Grid>
</Border>
<!--</StackPanel>-->
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
<Grid Grid.Row="1" >
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Button x:Uid="CreateButton" Name="CreateButton" Grid.Column="0" HorizontalAlignment="Stretch" Margin="5 0" Style="{StaticResource ApplicationThemeButtonStyle}" Click="CreateButton_Click" />
</Grid>
</Grid>
在上navigatedTo功能它臨危從之前的屏幕,返回正常的列表,所以它轉換成可觀察的名單第一然後分配給列出這樣的名單。
defaultViewModel.Add("ViolationList", violations);
可以請你分享一份代碼清單嗎?你如何創建它?它是否在其他控件內?因此,列表中沒有限制,至少不是20個項目。可能還有其他一些問題。 – Nishi
我已經添加了代碼 – Yawar
我不知道爲什麼,我只是提供列表視圖高度自動幷包裝其周圍的scrollviewer和問題解決。 – Yawar