在窗口电话8.1运行时滚动时保持文本块在视图中

时间:2015-07-30 08:19:04

标签: windows-phone-8.1

my problem is exactly similar to this article

但我需要在wp8.1运行时实现。我在滚动时想要textblock(name = txt_latest_update)

这是我的XAML代码

<Grid Name="Root_content" Background="#FFF7FDF7">
    <Grid.RowDefinitions>
        <RowDefinition Height="70"/>          
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>

    <Border Grid.Row="0" Background="Red">
        <Image Source="/Assets/nepaltoday.png" HorizontalAlignment="Left" Margin="10,0,0,0"/>     
    </Border>

    <ScrollViewer Grid.Row="1"   Name="frontpage_scrollview" VerticalScrollBarVisibility="Visible" 
                  >            
        <StackPanel>
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="300"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Grid Grid.Row="0">
                    <Image Name="startscren"  Stretch="Fill"/>
                    <Grid>
                        <Grid.Background>
                            <LinearGradientBrush StartPoint="0.3,0" EndPoint="1,0.">
                                <GradientStop Color="Transparent" Offset="0"/>
                                <GradientStop Color="Black" Offset="1.2" />
                            </LinearGradientBrush>
                        </Grid.Background>
                    </Grid>
                    <Grid HorizontalAlignment="Right" Margin="0,10,10,0">
                        <StackPanel>
                            <TextBlock Name="txt_nepali_date" Foreground="White" FontSize="26"/>
                            <TextBlock Name="txt_eng_date" Foreground="White" FontSize="26" />
                            <TextBlock Name="txt_temp"  Foreground="Yellow" FontSize="44" Margin="0,20,0,0"/>
                            <TextBlock Name="txt_location" FontSize="22"/>                       
                       </StackPanel>
                    </Grid>
                </Grid>

                <Grid Grid.Row="1">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>

                    <Grid.Resources>
                        <Style TargetType="Button">
                            <Setter Property="BorderBrush" Value="LightGray"/>
                            <Setter Property="BorderThickness" Value="0,1,1,1"/>
                            <Setter Property="Height" Value="Auto"/>
                            <Setter Property="Margin" Value="0,0,0,-20"/>
                        </Style>
                    </Grid.Resources>

                    <StackPanel Grid.Column="0">
                        <Button Name="btnNews" Click="btnNews_Click">
                            <Image Source="/Assets/FrontPage/horoscope.png" VerticalAlignment="Stretch"/>
                        </Button>
                        <Button Name="btnHoroscope" Click="btnHoroscope_Click">
                            <Image Source="/Assets/FrontPage/horoscope.png"/>
                        </Button>
                        <Button Name="btnCurrencyExchanges" Click="btnCurrencyExchanges_Click">
                            <Image Source="/Assets/FrontPage/currency exchange.png"/>
                        </Button>
                        <Button Name="btnStockExchanges" Click="btnStockExchange">
                            <Image Source="/Assets/FrontPage/on this day.png"/>
                        </Button>
                        <Button Name="btnOnthisday" Click="btnOnthisday_Click">
                            <Image Source="/Assets/FrontPage/horoscope.png"/>
                        </Button>
                        <Button Name="btnMovie" Click="btnMovie_Click">
                            <Image Source="/Assets/FrontPage/horoscope.png"/>
                        </Button>
                    </StackPanel>

                    <StackPanel Grid.Column="1" >
                        <Button Name="btnWeather" Click="btnWeather_Click">
                            <Image Source="/Assets/FrontPage/whether.png"/>
                        </Button>
                        <Button Name="btnLoadshedding" Click="btnLoadshedding_Click">
                            <Image Source="/Assets/FrontPage/loadshedding.png"/>
                        </Button>
                        <Button Name="btnGoldSilver" Click="btnGoldSilver_Click">
                            <Image Source="/Assets/FrontPage/gold_silver rates.png"/>
                        </Button>
                        <Button Name="btnTheatre" Click="btnTheatre_Click">
                            <Image Source="/Assets/FrontPage/theater.png"/>
                        </Button>
                        <Button Name="btnCalendar" Click="btnCalendars">
                            <Image Source="/Assets/FrontPage/horoscope.png"/>
                        </Button>
                    </StackPanel>
                </Grid>
            </Grid>              
        </StackPanel  > 
    </ScrollViewer>

    <Border Name="TitleBorder" Grid.Row="1"
             Background="#FF264778" Opacity="0.7"
             Margin="0,260,0,0" 
             Height="{Binding ElementName=TitleText, Path=Height}" 
             VerticalAlignment="Top">

        <TextBlock Name="txt_lastest_update" HorizontalAlignment="Center"   
                   Text="keep in view"
                   Foreground="White" 
                   FontSize="22"
                   Margin="12" />
    </Border>
</Grid>

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

嘿,我认为你的问题是,你希望在列表滚动时保持你的文本块固定。所以你必须将你的列表保存在需要修复的不同网格中的不同网格和文本块中。并制作包含列表scrolable = true的网格。