TexBlock在Popup中滚动

时间:2015-05-11 07:10:09

标签: c# popup windows-store-apps scrollviewer

我在弹出窗口(C#,Windows应用商店应用)中滚动TextBlock文本时遇到问题。

我在Popup中有一个TextBlock。我需要能够滚动文本,当它大于弹出窗口大小时,但它不会滚动,它会删除部分文本,而不适合。

我试过这段代码:

<Popup>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<TextBlock x:Name="PopupHeader" Grid.Row="0" Text="Header"/>
<ScrollViewer Grid.Row="1">
<TextBlock x:Name="PopupContent" Text="Main text" HorizontalAlignment="Stretch" TextAlignment="Justify" TextWrapping="Wrap"/>
</ScrollViewer>
</Grid>
</Popup>

我从代码中设置TextBlock文本,Popup和TextBlock高度。 任何人都可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

你需要在TextBlock中放置高度和宽度。

&#13;
&#13;
 <Popup  HorizontalAlignment="Stretch"
                VerticalAlignment="Stretch"
                IsOpen="True">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto" />
                    <RowDefinition Height="auto" />
                </Grid.RowDefinitions>
                <TextBlock x:Name="PopupHeader"
                           Grid.Row="0"
                           Text="Header" />

                <ScrollViewer Grid.Row="1"
                              VerticalScrollBarVisibility="Visible">
                    <TextBlock x:Name="PopupContent"
                               Width="put width here" Height="put height here"
                               TextWrapping="Wrap"
                               Text="Somthing really long text here"
                               TextAlignment="Justify" />

                </ScrollViewer>

            </Grid>
        </Popup>
&#13;
&#13;
&#13;