开发者

WPF: Wrapping multi-part text

开发者 https://www.devze.com 2022-12-18 02:49 出处:网络
Currently I\'m using a TextBlock to开发者_如何学Python show a single line with an image. <TextBlock>

Currently I'm using a TextBlock to开发者_如何学Python show a single line with an image.

<TextBlock>
    <Image Name="StatusImage"  Stretch="Fill" MaxWidth="12" MaxHeight="12"
           Source="/Aam.Cerberus.Applications;component/Images/Warning.png"></Image>
    <TextBlock Text="{Binding Path=ServiceStatusText}"></TextBlock>
    <TextBlock Text=" ("></TextBlock>
    <TextBlock Text="{Binding Path=ServiceMachineName}"></TextBlock>
    <TextBlock Text=")"></TextBlock>
</TextBlock>

My questions are:

  1. Is a TextBlock the right way to do this sort of thing?
  2. How do I enable word wrapping?


You want the TextWrapping="Wrap" property.

However, according to the MSDN

TextBlock is not optimized for scenarios that need to display more than a few lines of content; for such scenarios, a FlowDocument coupled with an appropriate viewing control is a better choice than TextBlock, in terms of performance.

0

精彩评论

暂无评论...
验证码 换一张
取 消