UWP:首次加载时,Listview显示灰色背景的时间少于一秒,然后在实际内容之前消失

时间:2019-05-02 15:54:44

标签: c# xaml uwp

每次首次加载列表视图时,它都会闪烁灰色背景少于半秒,然后在加载实际内容之前消失。我的代码如下(很简单),有什么想法吗?

<ListView Name="FilterCategories" SelectionMode="None"
                                  FlowDirection="LeftToRight" >
                            <ListView.ItemContainerTransitions>
                                <TransitionCollection/>
                            </ListView.ItemContainerTransitions>
                            <ListView.ItemTemplate>
                                <DataTemplate x:DataType="filter:FilterCategory">                            
                                    <Grid Name="FilterHeaders">
                                        <Grid.ColumnDefinitions>
                                            <ColumnDefinition Width="*"/>
                                            <ColumnDefinition Width="Auto"/>
                                        </Grid.ColumnDefinitions>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="*"/>
                                            <RowDefinition Height="*"/>
                                            <RowDefinition Height="*"/>
                                        </Grid.RowDefinitions>
                                        <Grid>
                                            <TextBlock Name="Header" FontSize="13" FontWeight="Bold"
                                                       Margin="20,10,0,0" Text="{x:Bind NameAlias}" 
                                                       Opacity="{x:Bind Opacity}"
                                                       Grid.Column="0"/>
                                        </Grid>
                                        <RelativePanel Grid.Column="1" Margin="0,5,15,0">
                                            <TextBlock Name="DownArrow" Text="&#xE70D;" FontFamily="Segoe MDL2 Assets" FontSize="8" 
                                                             Visibility="{x:Bind IsCollapsed}" Grid.Column="1" TextAlignment="Left"
                                                             FontWeight="Bold"
                                                             Tapped="DownArrow_Tapped" RelativePanel.AlignRightWithPanel="True" Margin="0,10,10,0">
                                            </TextBlock>
                                            <TextBlock Name="UpArrow" Text="&#xE70E;" FontFamily="Segoe MDL2 Assets" FontSize="8" 
                                                               Visibility="{x:Bind IsExpand}" RelativePanel.AlignRightWithPanel="True"
                                                               TextAlignment="Left" FontWeight="Bold"
                                                               Tapped="UpArrow_Tapped" Margin="0,10,10,0">
                                            </TextBlock>
                                        </RelativePanel>                                
                                        <Grid  Grid.Row="1" Grid.ColumnSpan="2"
                                               Visibility="{Binding ElementName=UpArrow,Path=Visibility}"
                                               Margin="10,10,0,0">
                                            <ListView SelectionMode="None" ItemsSource="{x:Bind FilterCategoryItems}"
                                                                  ScrollViewer.VerticalScrollMode="Enabled">
                                                <ListView.ItemContainerTransitions>
                                                    <TransitionCollection/>
                                                </ListView.ItemContainerTransitions>                                                
                                                <ListView.ItemTemplate>
                                                    <DataTemplate x:DataType="filter:FilterCategoryItem">
                                                        <Grid>
                                                            <Grid.ColumnDefinitions>
                                                                <ColumnDefinition Width="30" />
                                                                <ColumnDefinition Width="Auto"/>
                                                            </Grid.ColumnDefinitions>
                                                            <CheckBox x:Name="FilterCheckBoxTask" Style="{StaticResource CheckBoxStylePlainView}" 
                                                                                                  IsThreeState="False" Opacity="0.2"
                                                                                                  MinWidth="10" VerticalAlignment="Center"/>
                                                            <TextBlock Grid.Column="1" Text="{x:Bind NameAlias}" VerticalAlignment="Center"/>
                                                        </Grid>
                                                    </DataTemplate>
                                                </ListView.ItemTemplate>
                                            </ListView>                                     
                                        </Grid>
                                        <Border BorderThickness="0,0,0,1" Height="10" 
                                                HorizontalAlignment="Stretch"
                                                BorderBrush="#f0f0f0" Grid.Row="2" Grid.ColumnSpan="2"/>
                                    </Grid>
                                </DataTemplate>                         
                            </ListView.ItemTemplate>
                        </ListView>

正在使用后面的代码动态设置商品来源

enter image description here

0 个答案:

没有答案