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>
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.
TextBlock is not editable.
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.
You cannot use the Inlines
(the Run
child nodes) and the TextBlock.Text
at the same time.
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