我是这个论坛的新手,也是Windows Phone 8开发的新手。
我有以下代码
<Grid x:Name="LayoutRoot" Background="#EEF8E5" Loaded="LayoutRoot_Loaded">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<!--TitlePanel contains the name of the application and page title-->
<TextBlock x:Name="ApplicationTitle" FontWeight="Bold" Padding="20,0,0,0" Grid.Row="0" Text="فرآن کریم"/>
<ScrollViewer Grid.Row="1" VerticalScrollBarVisibility="Visible"
x:Name="Scroller" VerticalContentAlignment="Top" >
<Grid x:Name="ContentPanel" Margin="20,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="70"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<TextBlock x:Name="txtBismullah" FontSize="40" HorizontalAlignment="Center" Grid.Row="0"></TextBlock>
<TextBlock x:Name="txt" FontSize="40" Grid.Row="1" TextWrapping="Wrap" />
</Grid>
</ScrollViewer>
<Grid Grid.Row="2" Background="Silver" VerticalAlignment="Bottom">
<Button Content="1" Width="100" BorderThickness="0" VerticalAlignment="Top" Click="Button_Click"></Button>
</Grid>
</Grid>
和c#
string readData()
{
string suraIndex = string.Empty;
int counter = 1;
for (int i = 0; i < 40; i++)
suraIndex += counter++ + Environment.NewLine;
return suraIndex;
}
最后
txt.Text += readData();
txt.Text += " I am Here";
问题是,它没有显示所有文本,它只显示最多35(因为滚动条有滚动)但没有显示文本。
我不知道文本块有什么问题,或者可能是它的高度,尽管它被设置为自动。
答案 0 :(得分:0)
您应该将TextBlock
放在ScrollViewer
而不是整个Grid
<Grid Grid.Row="1" x:Name="ContentPanel" Margin="20,0,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="70"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<TextBlock x:Name="txtBismullah" FontSize="40" HorizontalAlignment="Center" Grid.Row="0"/>
<ScrollViewer x:Name="Scroller" Grid.Row="1" VerticalScrollBarVisibility="Visible" VerticalContentAlignment="Top" >
<TextBlock x:Name="txt" FontSize="40" Grid.Row="1" TextWrapping="Wrap" />
</ScrollViewer>
</Grid>
答案 1 :(得分:0)
使用列表框而不是文本块对其进行排序。