I have a window that displays text. There are two parts to the text: the first is fixed while the second needs to be the content of a DependencyProperty declared on the window.
I considered using a TextBlock containing two Spans, the first of which contains the fixed content and the second of which contains the variable content, but I can't see anything obvious on the Span class that would allow me to bind to the aforementioned DependencyProperty.
I'm currently using two Labels stacked side by side but this is ugly and doesn't help me if I wish to retrieve the content of the entire text block (as I do when displaying a ToolTip in the event that the window is too narrow to display the entire text block).
Can anyone help me to crack this seemingly simple problem? Thanks.
If you're using .NET 4:
<TextBlock>
<Run Text="Fixed:"/>
<Run Text="{Binding Variable}"/>
</TextBlock>
Prior to .NET 4, the Run
's Text
property was not a dependency property.
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