0

I have a pivot have 2 itempivot. When I debug the app show as below:

enter image description here

After I close debug, open app it show as below:

enter image description here

Why it is show like that?

Below code

enter code here

<Page
    x:Class="WindowsPhone_Crawler.Views.CategoryPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:WindowsPhone_Crawler.Views"
    xmlns:controls="using:WindowsPhone_Crawler.Controls"
    xmlns:converters="using:WindowsPhone_Crawler.Converter"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">

    <Grid>
  <Grid x:Name="LayoutRoot" Background="#ebebeb">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <Pivot Grid.Row="1" 
                           Margin="-20,-35,-20,0" 
                           x:Name="MyPvNews" 
                           SelectionChanged="MyPvNews_SelectionChanged">
                        <PivotItem Background="#ebebeb" x:Name="PvHotNews">
                            <Grid Grid.Row="1" Background="#ebebeb">
                                <ScrollViewer Name="OuterScroll" Loaded="OuterScroll_Loaded" ViewChanged="OuterScroll_ViewChanged">
                                    <Grid>
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="60"/>
                                            <RowDefinition Height="Auto"/>
                                        </Grid.RowDefinitions>

                                        <Grid Grid.Row="0" Background="#ebebeb">
                                            <Image Source="/Assets/down13.png" Height="40" Width="40" HorizontalAlignment="Left" Margin="20,0,0,0">
                                                <Image.RenderTransform>
                                                    <RotateTransform x:Name="RefreshIndicatiorRotateTransform" CenterX="20" CenterY="20"/>
                                                </Image.RenderTransform>
                                            </Image>
                                            <TextBlock Name="RefreshIndicatiorTextBlock" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="80,0,0,0" Width="200" Foreground="Black"/>
                                        </Grid>
                                        <ListView x:Name="listViewHotNews" Grid.Row="1" IsItemClickEnabled="True" SelectionChanged="listViewHotNews_SelectionChanged" ItemClick="listViewHotNews_ItemClick">
                                            <ListView.ItemContainerStyle>
                                                <Style TargetType="ListViewItem">
                                                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                                                    <Setter Property="VerticalContentAlignment" Value="Stretch"/>
                                                </Style>
                                            </ListView.ItemContainerStyle>
                                            <ListView.ItemTemplate>
                                                <DataTemplate>
                                                    <Border BorderBrush="LightGray" BorderThickness="0,0,0,1">
                                                        <Grid>
                                                            <Grid.ColumnDefinitions>
                                                                <ColumnDefinition Width="0.4*"/>
                                                                <ColumnDefinition Width="*"/>
                                                            </Grid.ColumnDefinitions>
                                                            <Grid.RowDefinitions>
                                                                <RowDefinition Height="*"/>
                                                                <RowDefinition Height="*"/>
                                                            </Grid.RowDefinitions>
                                                            <Image Grid.RowSpan="2" Grid.Column="0" Source="{Binding Image, Converter={StaticResource StringToImageConverter}}"/>
                                                            <TextBlock Text="{Binding Title}" MaxLines="3" TextTrimming="WordEllipsis" Foreground="Black" TextWrapping="Wrap" Grid.Row="0" Grid.Column="1" FontSize="20" FontWeight="Medium" Margin="15,12,0,0"/>
                                                            <StackPanel Orientation="Horizontal" Margin="15,0,0,0" Grid.Row="1" Grid.Column="1">
                                                                <TextBlock Foreground="Blue" Text="{Binding Name}" TextWrapping="Wrap" Grid.Row="1" Grid.Column="1" FontSize="15" FontWeight="Medium"/>
                                                                <TextBlock Foreground="Gray" Text="{Binding Modified_date, Converter={StaticResource TimesConverter}}" TextWrapping="Wrap" Grid.Row="1" Grid.Column="2" FontSize="15" FontWeight="Medium" Margin="5,0,0,0"/>
                                                            </StackPanel>
                                                        </Grid>
                                                    </Border>
                                                </DataTemplate>
                                            </ListView.ItemTemplate>
                                        </ListView>
                                        <TextBlock x:Name="TbNoHotNews" VerticalAlignment="Center" Grid.Row="1" FontSize="22" FontWeight="Bold" Foreground="Black" HorizontalAlignment="Center" Visibility="Collapsed">Không có tin nào !</TextBlock>
                                    </Grid>
                                </ScrollViewer>
                            </Grid>
                        </PivotItem>
                        <PivotItem  Background="#ebebeb" x:Name="PvNews">
                            <Grid Grid.Row="1" Background="#ebebeb">
                                <GridView x:Name="gridViewTopic" Grid.Row="1"
                                          SizeChanged="gridViewTopic_SizeChanged" 
                                          SelectionChanged="gridViewTopic_SelectionChanged" 
                                          ItemClick="gridViewTopic_ItemClick" 
                                          IsItemClickEnabled="True"
                                          ScrollViewer.VerticalScrollMode="Enabled"
                                          ScrollViewer.VerticalScrollBarVisibility="Hidden"
                                          ScrollViewer.HorizontalScrollBarVisibility="Disabled">
                                    <GridView.ItemContainerStyle>
                                        <Style TargetType="GridViewItem">
                                            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                                            <Setter Property="VerticalContentAlignment" Value="Stretch"/>
                                        </Style>
                                    </GridView.ItemContainerStyle>
                                    <GridView.ItemsPanel>
                                        <ItemsPanelTemplate>
                                            <ItemsWrapGrid MaximumRowsOrColumns="2"   Orientation="Horizontal"/>
                                        </ItemsPanelTemplate>
                                    </GridView.ItemsPanel>
                                    <GridView.ItemTemplate>
                                        <DataTemplate>
                                            <Grid Visibility="{Binding Regis, Converter={StaticResource VisibilityConverter}}">
                                                <Grid.ColumnDefinitions>
                                                    <ColumnDefinition Width="0.5*"/>
                                                </Grid.ColumnDefinitions>
                                                <Grid Margin="10" >
                                                    <Grid.Background>
                                                        <ImageBrush ImageSource="{Binding IconLink, Converter={StaticResource StringToImageConverter}}" />
                                                    </Grid.Background>
                                                    <TextBlock Foreground="White"  Text="{Binding TopicName}" FontSize="23"></TextBlock>
                                                </Grid>
                                            </Grid>
                                        </DataTemplate>
                                    </GridView.ItemTemplate>
                                </GridView>
                                <TextBlock x:Name="TbNoNews" VerticalAlignment="Center" Grid.Row="1" FontSize="22" FontWeight="Bold" Foreground="Black" HorizontalAlignment="Center" Visibility="Collapsed">Không có tin nào !</TextBlock>
                            </Grid>
                        </PivotItem>
                    </Pivot>
                    <ProgressRing x:Name="myLoading" Grid.Row="1" Background="White" Foreground="Blue" IsActive="True"></ProgressRing>
                    <Grid Background="#008FE5" Grid.Row="0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Grid Grid.Column="0">
                            <ToggleButton Margin="10,20,-30,-10" Background="Transparent" VerticalAlignment="Center" IsChecked="{Binding IsLeftPaneOpen, ElementName=HamburgerMenu, Mode=TwoWay}" Style="{StaticResource HamburgerToggleButton}" />
                        </Grid>
                        <Grid Grid.Column="1" Margin="0,0">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Grid Background="Transparent" x:Name="GHotNews" Tapped="GHotNews_Tapped" >
                                <TextBlock x:Name="TbHotNews" Text="Tin hot" FontSize="22" Foreground="White" FontWeight="Bold" VerticalAlignment="Center"/>
                                <Line x:Name="LHotNews" X1="0" X2="80" Stroke="#FF8B3D" StrokeThickness="2" VerticalAlignment="Bottom">
                                </Line>
                            </Grid>
                            <Grid Grid.Column="1" Background="Transparent" Margin="30,0,-50,0" x:Name="GNews" Tapped="GNews_Tapped" >
                                <TextBlock x:Name="TbNews" Text="Chuyên mục" FontSize="22" Foreground="White" FontWeight="Bold" Opacity="0.6" VerticalAlignment="Center"/>
                                <Line x:Name="LNews" X1="0" X2="125" Stroke="#FF8B3D" StrokeThickness="2" VerticalAlignment="Bottom" Visibility="Collapsed"/>
                            </Grid>
                        </Grid>
                    </Grid>
                </Grid>
            </Grid>
    </Grid>
</Page>    
4

1 回答 1

0

您是否为 ListViewItem 添加了样式?

<ListView>
    <ListView.ItemContainerStyle>
        <Style TargetType="ListViewItem">
            <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        </Style>
    </ListView.ItemContainerStyle>
</ListView>

这是公平的,对于 GridViewItem,如果您使用的是 GridView

于 2016-10-20T07:46:05.903 回答