问题描述
嗨
我想分别设置文本的对齐方式.我的意思是,当用户选择组合框项目时,他要键入的文本应居中对齐,并且左右必须有150个缩进.我可以实现居中对齐,但无法计算 找出一种缩进的方式.
I want to set the alignment of text individually. I mean, when a user selects a combobox item, the text he is going to type should center align and must have 150 indent from left and right. I able to achieve center alignment but could not able to figure out a way to indent.
对于中心对齐,我正在使用
For center alignment, I am using,
richTextBox.Selection.ApplyPropertyValue(Paragraph.TextAlignmentProperty, TextAlignment.Center);
现在我要设置缩进.我不确定,但是下面的代码必须有一个我无法解决的解决方案;
Now I want to set the indent. I am not sure but below code must have a solution which I cant able to figure out;
richTextBox.Selection.ApplyPropertyValue(Paragraph.TextIndentProperty,xxxxxxxxxxxxx);
richTextBox.Selection.ApplyPropertyValue(Paragraph.TextIndentProperty, xxxxxxxxxxxxx);
希望您了解我的要求.
Hope you understand my requirement.
推荐答案
const double margin = 10.0;
richTextBox1.Selection.ApplyPropertyValue(Paragraph.MarginProperty, new Thickness(left: margin, top: 0, right: margin, bottom: 0));
希望有帮助.
请记住,通过将有用的帖子标记为答案来关闭话题,然后在遇到新问题时开始新话题.请不要在同一线程中问几个问题.
Please remember to close your threads by marking helpful posts as answer and then start a new thread if you have a new question. Please don't ask several questions in the same thread.
这篇关于如何在富文本框中设置单个文本的缩进?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!