【问题标题】:How to clone FormattedText?如何克隆 FormattedText?
【发布时间】:2011-08-04 20:40:59
【问题描述】:

我有一个从函数中检索到的名为“oldf”的 FormattedText。

FormattedText oldf = GetFormattedText();

我想用 oldf 来创建 newf,除了文本之外完全一样。

我尝试过类似的方法:

    FormattedText newf = new FormattedText("myNewText",oldf.CultureInfo,oldf.FlowDirection,oldf.TypeFace,
        oldf.EmSize, oldf.Foreground);

但没有成功。

【问题讨论】:

  • @agent-j - 请尝试做我尝试过的事情,你会发现这是不可能的。
  • 您似乎试图滥用FormattedText。例如,一个 FormattedText 不一定只有一个 ForegroundBrush。因此SetForegroundBrush(Brush foregroundBrush, int startIndex, int count); 如果要重用该对象,为什么不直接设置Text 属性?

标签: c# .net wpf


【解决方案1】:

这些值是在构造函数中传递的参数,但它们不是可以在类中找到的属性:FormattedText Class

如果要重复这些值,则需要将它们存储在其他地方

(Text 属性是只读的)

【讨论】:

    猜你喜欢
    • 2010-10-17
    • 2012-05-27
    • 2012-06-17
    • 2010-12-30
    • 2015-01-26
    • 2011-03-31
    • 2011-08-20
    相关资源
    最近更新 更多