Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I would like 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.

like image 548
Ralph Shillington Avatar asked Oct 27 '10 19:10

Ralph Shillington


1 Answers

@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>
like image 126
Liam Avatar answered Sep 29 '22 15:09

Liam