开发者

Is there any way to set a binding on a TextBlock Span

I would li开发者_Python百科ke to use a several Span elements inside a TextBlock and have the content of the spans set by binding. I don't think this is possible, but wanted to double check here first.


@walkman123 is correct that you can't bind to span elements in XAML.

You might want to consider using Run elements rather than span elements as you can bind to these from within a TextBlock.

<TextBlock FontFamily="Arial" Width="400" Text="Company Information">
  <Run FontFamily="Courier New" FontSize="24" Text="{Binding CompanyName}" />
  <LineBreak/>
  <Run FontFamily="Courier New" FontSize="18" FontStyle="Italic" Text="{Binding CompanyAddress}" />
  <LineBreak/>
  <Run FontFamily="Courier New" FontSize="14" FontWeight="Bold" Text="{Binding CompanyPhone}" />
  <LineBreak/>
</TextBlock>


Yes, Span element value cannot be binded, because it is not a Framework Element, but Inline Element.

Only Framework Elements can be bound.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜