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.
@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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With