English 中文(简体)
Playcen 文本包装和样式发行
原标题:Playn text wrapping and style issue
  • 时间:2012-05-25 09:44:18
  •  标签:
  • styles
  • playn

在PlayN1.3.

TextFormat textFormat = new TextFormat(myFont, textWidth, Alignment.LEFT, colorCode, Effect.shadow(-16777216, shadowX, shadowY));

所以我把它改成这个:

TextFormat textFormat = new TextFormat();
textFormat.withFont(myFont);
textFormat.withWrapping(textWidth, Alignment.LEFT);

我现在不想有影子, 但我没有像结果一样得到前身。 等待, 不要现在思考。 然后我把这个代码改成了这个:

TextFormat textFormat = new TextFormat().withFont(myFont).withWrapping(textWidth, Alignment.LEFT);

It gives me result as previous except shadow which i dont care now.If i am not wrong this is one line representation of above code.Is not it? So why it worked and above code did not.Any conceptual difference is there? Anyone can explain please!

/注:不要担心变量(文字Width、MyFont),这些变量与这些变量无关。

最佳回答

文本格式对象不可更改。 当您调用文本Format. with Font( MyFont) 返回一个 new TextFormat 实例, 上面的代码正在丢弃它。 如果您想要第一个代码工作, 您需要这样写 :

TextFormat format = new TextFormat();
format = format.withFont(myFont);
format = format.withWrapping(textWidth, Alignment.LEFT);
问题回答

暂无回答




相关问题
Creating a Style in code behind

Does anyone know how to create a wpf Style in code behind, I can t find anything on the web or MSDN docs. I have tried this but it is not working: Style s = new Style(typeof(TextBlock)); s....

WPF Custom Themes

I have a simple question which is giving me some difficulty. I have downloaded a custom them for WPF of the net. Now i want to apply this theme to my App instead of the default one. How do i do that,...

Is it sometimes bad to use <BR />?

Is it sometimes bad to use <BR/> tags? I ask because some of the first advice my development team gave me was this: Don t use <BR/> ; instead, use styles. But why? Are there negative ...

WPF - How to apply effect to a cropped image?

I have an Image being clipped like so: <Image Width="45" Grid.Column="0" Source="{Binding Photo}"> <Image.Clip> <RectangleGeometry Rect="0,0,45,55" RadiusX="8" RadiusY="8" /...

WPF ListView : Header styling

I want to have a ListView with columns and a particular style: The background for ALL column headers should be transparent except when the mouse is over in one of them. When this happends, the ...

热门标签