wpf - XAML TextBlock 和运行绑定(bind)

标签 wpf xaml

我遇到了 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/

相关文章:

wpf - 枢轴控制 MVVM-Light-EventToCommand SelectedIndex 发送上一个索引

c# - 在 UIElementCollection 上使用 Where 表达式

.net - TFS On Premise Build Agent - 无法为 SSL/TLS 安全通道建立信任关系

wpf - ComboBox崩溃WPF应用程序,因为SelectionChanged触发得太早

c# - 是否可以使用非特殊文件夹作为 FolderBrowserDialog 的根文件夹?

c# - 了解 WPF 中提供的 DispatcherPriority 枚举的真实行为

wpf - XamlReader 生成 DataTemplate 的问题

c# - 为什么我的 ObservableCollection<MenuItem> 不会在 RaisePropertyChanged 上更新?

wpf - 当 IsSelected 和 TreeView 中使用的两种类型时更改 TreeViewItem 模板

wpf - 如何在面板中的另一个 WPF 窗口中加载一个 WPF (xaml) 窗口?