RichTextBox选中项居中
如题,并不是让整个文本居中
所以
- C# code
TextAlignment align = TextAlignment.Left; switch ((this.cmbStyles.SelectedValue as ComboBoxItem).Tag.ToString()) { case "左对齐": align = TextAlignment.Left; break; case "居中": align = TextAlignment.Center; break; case "右对齐": align = TextAlignment.Right; break; }
类似就不要一变又一遍的再发了。。。
[解决办法]
- C# code
TextAlignment align = TextAlignment.Left; switch ((this.cmbStyles.SelectedValue as ComboBoxItem).Tag.ToString()) { case "左对齐": align = TextAlignment.Left; break; case "居中": align = TextAlignment.Center; break; case "右对齐": align = TextAlignment.Right; break; } //将样式赋给富文本框的选中项 rtb_text.Selection.ApplyPropertyValue(Block.TextAlignmentProperty, align);