我遇到了 Run 绑定(bind)不起作用的问题。
这是我当前的代码。
<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>
我得到公司名称出现,但额外的数据从未出现。
任何想法为什么这种类型的绑定(bind)失败?
替代答案与最终答案
<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>
最佳答案
您不能使用 Inlines
(Run
子节点)和 TextBlock.Text
同时。
关于wpf - XAML TextBlock 和运行绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11882066/