Reputation: 1192
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>
Upvotes: 26
Views: 54581
Reputation: 1614
Also: make sure the bound value is String
.
Another potential cause, if you're finding that a binding works in <TextBlock Text="{Binding...}" />
but the same binding fails in <TextBlock><Run Text="{Binding...}"...
:
The <TextBlock Text=...
binding implicitly invokes ToString()
for non-string values, but <Run Text=
does not.
Upvotes: 0
Reputation: 185290
You cannot use the Inlines
(the Run
child nodes) and the TextBlock.Text
at the same time.
Upvotes: 33