简体   繁体   English

如何在 WPF 中的 Textbox/Richtextbox 中为所选文本制作粗体按钮?

[英]How can i make a button for Bold a selected text in Textbox/Richtextbox in WPF?

I need to make a Button for bolding selected text of a string in TextBox / RichTextBox , but I don't know how to do it with code behind.我需要在TextBox / RichTextBox制作一个用于将string选定文本加粗的Button ,但我不知道如何使用后面的代码来实现。

TextBox1.SelectedText = new FontStyle("Bold")

It is not working.它不工作。

试试这个富文本框的代码:

RichTextBox1.Selection.ApplyPropertyValue(TextElement.FontWeightProperty, FontWeights.Bold);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM