Wpf 一个文本框中字体的多模块文本字体大小
我有以下代码Wpf 一个文本框中字体的多模块文本字体大小,wpf,vb.net,text,textbox,Wpf,Vb.net,Text,Textbox,我有以下代码 TextBox1.Text = "Two of the peak human experiences are " TextBox1.Text = TextBox1.Text & "good food and classical music." TextBox1.FontSize = "16" 它在同一文本框中显示两行。如何更改每行文本的字体大小并使其显示在同一文本框中?请改用richtextbox richTextBox1.SelectionFont =
TextBox1.Text = "Two of the peak human experiences are "
TextBox1.Text = TextBox1.Text & "good food and classical music."
TextBox1.FontSize = "16"
它在同一文本框中显示两行。如何更改每行文本的字体大小并使其显示在同一文本框中?请改用richtextbox
richTextBox1.SelectionFont = new Font("Arial", 12, FontStyle.Bold);
richTextBox1.AppendText("Two of the peak human experiences are");
richTextBox1.SelectionFont = new Font("Tahoma", 16, FontStyle.Bold);
richTextBox1.AppendText("good food and classical music");
改用richtextbox
richTextBox1.SelectionFont = new Font("Arial", 12, FontStyle.Bold);
richTextBox1.AppendText("Two of the peak human experiences are");
richTextBox1.SelectionFont = new Font("Tahoma", 16, FontStyle.Bold);
richTextBox1.AppendText("good food and classical music");
您不能使用文本框,但可以使用RichTextBox:
<RichTextBox>
<RichTextBox.Resources>
<Style x:Key="Bigger">
<Setter Property="FontSize" Value="16"/>
</Style>
</RichTextBox.Resources>
<FlowDocument>
<Paragraph>
This is the first paragraph.
</Paragraph>
<Paragraph Style={StaticResource Bigger}>
This is the second paragraph.
</Paragraph>
</FlowDocument>
</RichTextBox>
这是第一段。
这是第二段。
您不能使用文本框,但可以使用RichTextBox:
<RichTextBox>
<RichTextBox.Resources>
<Style x:Key="Bigger">
<Setter Property="FontSize" Value="16"/>
</Style>
</RichTextBox.Resources>
<FlowDocument>
<Paragraph>
This is the first paragraph.
</Paragraph>
<Paragraph Style={StaticResource Bigger}>
This is the second paragraph.
</Paragraph>
</FlowDocument>
</RichTextBox>
这是第一段。
这是第二段。