这一次真的让我抓狂。默认情况下,RichTextBox会在新段落的开头插入额外的一行。我认为将段落边距属性设置为零可以防止这种行为,但只能在xaml中看到示例...我试过了
.Selection.ApplyPropertyValue(Paragraph.MarginProperty, 0.0)但是这会抛出一个错误,告诉我'0‘不是属性’边距‘的有效值。
和
.Resources.Add(Paragraph.MarginProperty, 0.0)但那没有任何效果。
发布于 2013-07-20 08:09:01
边距是一个Thickness类型--
.Selection.ApplyPropertyValue(Paragraph.MarginProperty, new Thickness(0))要添加到Resources,请添加针对Paragraph类型的样式:
Style paragraphStyle = new System.Windows.Style { TargetType = typeof(Paragraph) };
paragraphStyle.Setters.Add(new Setter {
Property = Paragraph.MarginProperty,
Value = new Thickness(0) });
.Resources.Add(null, paragraphStyle);https://stackoverflow.com/questions/17757263
复制相似问题