2011-08-04 156 views
0

我有一个名为“oldf”的FormattedText,它是从一个函数中获取的。如何克隆FormattedText?

FormattedText oldf = GetFormattedText(); 

我想使用oldf创建newf,除了文本以外完全相同。

我想类似的东西:

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

,但没有成功。

+0

什么是未复制? –

+0

@ agent-j - 请尝试做我尝试过的东西,你会发现这是不可能的。 – Erez

+0

它看起来像你试图滥用'FormattedText'。例如,FormattedText不一定只有一个ForegroundBrush。因此,'SetForegroundBrush(Brush foregroundBrush,int startIndex,int count);'如果你想重新使用这个对象,为什么不直接设置'Text'属性呢? –

回答

0

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

如果你要重复的值,则需要将它们存储在别处

(文本属性为只读)