C# 如何在windows 8应用程序的文本框中添加滚动?
我想在windows 8应用程序的文本框中添加滚动查看器。这样用户就可以滚动浏览他的长文本了,在XAML中添加一个scrollviewer。然后通过剪切和粘贴文本框的边距来设置scrollviewer的边距,并将文本框的高度和宽度设置为C# 如何在windows 8应用程序的文本框中添加滚动?,c#,windows-8,C#,Windows 8,我想在windows 8应用程序的文本框中添加滚动查看器。这样用户就可以滚动浏览他的长文本了,在XAML中添加一个scrollviewer。然后通过剪切和粘贴文本框的边距来设置scrollviewer的边距,并将文本框的高度和宽度设置为auto我刚刚重写了Harshit解释的内容,并添加了一些图片和代码 将scrollviewer添加到XAML 在Scrollviewer中选择边距(最佳方式:单击XAML中的TestViewer代码以选择边距) 将边距值设置为“自动” 粘贴(在XAML中)文本框
auto
我刚刚重写了Harshit解释的内容,并添加了一些图片和代码
<Page
x:Class="testapp.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:newcalapp_winrt"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="0,4,0,-4">
<Button Click="showText" Content="ShowText" x:Name="btn" Width="200" Height="56" Margin="1037,620,0,92"></Button>
<ScrollViewer x:Name="outputTextBoxScrollViewer" Margin="57,200,700,400">
<TextBox x:Name="outputTextBox" AcceptsReturn="True"/>
</ScrollViewer>
<ScrollViewer x:Name="outputTextBlockScrollViewer" Margin="57,450,700,169">
<TextBlock x:Name="outputTextBlock"/>
</ScrollViewer>
</Grid>
</Page>
namespace testapp
{
public sealed partial class MainPage : Page
{
public MainPage()
{
this.InitializeComponent();
}
void showText(object sender, RoutedEventArgs args)
{
//OutputString
String outputString;
//Random number
Random randomizer = new Random();
int randomNumber = randomizer.Next(0,100000);
//Some magic with Dates :) Not important!
...
outputTextBox.Text = outputString;
outputTextBlock.Text = outputString;
}
}
}