关于richtextbox的XAML属性

a121984376 2010-08-23 04:47:47
ritchtextbox的XAML属性赋值的时候出现一些问题.
字符串:

<Section xml:space="preserve" HasTrailingParagraphBreakOnPaste="False" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"><Paragraph FontSize="11" FontFamily="Portable User Interface" Foreground="#FF000000" FontWeight="Normal" FontStyle="Normal" FontStretch="Normal" TextAlignment="Left">
<Run Text="aaa" />
</Paragraph><Paragraph FontSize="11" FontFamily="Portable User Interface" Foreground="#FF000000" FontWeight="Normal" FontStyle="Normal" FontStretch="Normal" TextAlignment="Left">
<Run Text="aaaa" />
</Paragraph></Section>

赋值后就成了这样:

<Section xml:space="preserve" HasTrailingParagraphBreakOnPaste="False" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"><Paragraph FontSize="11" FontFamily="Portable User Interface" Foreground="#FF000000" FontWeight="Normal" FontStyle="Normal" FontStretch="Normal" TextAlignment="Left">
<Run Text="aaa" />
<Run Text="" />
</Paragraph>
<Paragraph FontSize="11" FontFamily="Portable User Interface" Foreground="#FF000000" FontWeight="Normal" FontStyle="Normal" FontStretch="Normal" TextAlignment="Left">
<Run Text="aaaa" />
<Run Text="" />
</Paragraph></Section>


每一行多了一个<Run Text="" />,这是怎么回事???
...全文
177 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
swt839 2010-08-29
  • 打赏
  • 举报
回复

也可以用这种方式绑定
  
Paragraph nw1 = new Paragraph();
Run r3 = new Run();
r3.Text += "要显示的内容 " ;
nw1.Inlines.Add(r3);
rtbChat.Selection.Insert(nw1);
pkjijie 2010-08-27
  • 打赏
  • 举报
回复
好好看看richbox的api
bryht 2010-08-27
  • 打赏
  • 举报
回复
是不是你赋值的过程有问题?
a121984376 2010-08-26
  • 打赏
  • 举报
回复
没人回复呢~~~???
badi888 2010-08-23
  • 打赏
  • 举报
回复
可能和richtextbox中的空格有关吧。。。
帮顶。。。。

8,736

社区成员

发帖
与我相关
我的任务
社区描述
WPF/Silverlight相关讨论
社区管理员
  • WPF/Silverlight社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧