C# 通过XAML代码在WPF文本框中生成多行文本
1-将以下代码复制并粘贴到MainWindow.xaml文件中C# 通过XAML代码在WPF文本框中生成多行文本,c#,wpf,xaml,C#,Wpf,Xaml,1-将以下代码复制并粘贴到MainWindow.xaml文件中 <Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<StackPanel>
<Button x:Name="Button1" Height="25" Width="100" Content="Press Me" Click="Button1_Click"/>
<TextBox x:Name="TextBox1" Width="400" Height="200" TextWrapping="Wrap" TextAlignment="Justify" AcceptsReturn="True"/>
</StackPanel>
private void Button1_Click(object sender, RoutedEventArgs e)
{
System.Text.StringBuilder myStringBuilder = new System.Text.StringBuilder();
myStringBuilder.Append("Orange").AppendLine();
myStringBuilder.Append("").AppendLine();
myStringBuilder.Append("Apple").AppendLine();
myStringBuilder.Append("Banana").AppendLine();
myStringBuilder.Append("").AppendLine();
myStringBuilder.Append("Plum").AppendLine();
TextBox1.Text = myStringBuilder.ToString();
}
3-运行此项目,然后按按钮1
我的问题:
如何仅通过XAML代码管理期望的结果
(我不想使用C代码)问题:
包含我相信你的问题的答案
<TextBox x:Name="TextBox1" Width="400" Height="200" TextWrapping="Wrap" TextAlignment="Justify" AcceptsReturn="True" Text="A
B" />