8,737
社区成员
发帖
与我相关
我的任务
分享
<WrapPanel HorizontalAlignment="Stretch">
<TextBox x:Name="txt1" Height="30" Width="300" Margin="5" HorizontalAlignment="Stretch"></TextBox>
<ComboBox x:Name="myCombobox" Width="120" Height="30" HorizontalAlignment="Stretch">
<ComboBoxItem>10</ComboBoxItem>
<ComboBoxItem>12</ComboBoxItem>
<ComboBoxItem>14</ComboBoxItem>
<ComboBoxItem>16</ComboBoxItem>
<ComboBoxItem>18</ComboBoxItem>
</ComboBox>
<Button x:Name="btnConverter" Content="Converter" Width="240" Height="30" Margin="5" Click="btnConverter_Click"></Button>
<RichTextBox x:Name="myRichTextBox" Height="180" Margin="5"></RichTextBox>
</WrapPanel>
private void btnConverter_Click(object sender, RoutedEventArgs e)
{
string firstTxt = txt1.Text;
string fontSize = myCombobox.Text;
Run r = new Run();
r.FontSize = Convert.ToDouble(fontSize);
r.Text = firstTxt;
myRichTextBox.Document.Blocks.Add(new Paragraph(r));
}