Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XAML TextBlock and Run binding

Tags:

I have a problem where the binding of the Run does not work. Here's my current code.

<TextBlock   x:Name="txtCompanyName"   Text="{Binding Path=SelectedItem.CompanyName, ElementName=lbSourceList}"   Foreground="White"   FontSize="18.667"   Height="33.667"    Margin="10,-0.5,0,-1.5">   <Run Text=" : " Foreground="White"/>   <Run Text=" "/>   <Run Text=" " Foreground="White"/>   <Run Text=" "/>   <Run Text="{Binding Path=SelectedItem.RFQID, ElementName=lbSourceList}" /> </TextBlock> 

I am getting the company name appears but the extra data never shows up. Any ideas why this type of binding fails?


Alternate Answer Along With Final Answer

<TextBlock TextWrapping="Wrap"             Text="{Binding RFQID}"              FontWeight="Bold"              Foreground="#FFFFF504"              HorizontalAlignment="Left" Width="185">              <Run Text=" ~ "/>              <Run Text="{Binding RFQNo}" FontWeight="Bold" Foreground="#FFFFF504"/>              <Run Text=" ~ "/>              <Run Text="{Binding Status}" FontWeight="Bold"                                           Foreground="#FF85F35F"/>  </TextBlock> 
like image 423
scottsanpedro Avatar asked Aug 09 '12 11:08

scottsanpedro


People also ask

How does binding work in XAML?

Data binding is a mechanism in XAML applications that provides a simple and easy way for Windows Runtime Apps using partial classes to display and interact with data. The management of data is entirely separated from the way the data is displayed in this mechanism.

Is TextBlock editable?

TextBlock is not editable.

What is the difference between TextBox and TextBlock in WPF?

Text inside a TextBlock can not be made selectable by the user. TextBoxes are used for displaying text more focused for content input or when content is needed to be made selectable by the user. The TextBox can only be set to one colour, one font size, one font type etc.


1 Answers

You cannot use the Inlines (the Run child nodes) and the TextBlock.Text at the same time.

like image 97
H.B. Avatar answered Oct 11 '22 10:10

H.B.