wpf - 在 TextBlock 中使用绑定(bind)硬编码文本

标签 wpf xaml data-binding textblock

在 WPF 中,有没有办法让 TextBlockText 属性包含硬编码文本和特定绑定(bind)?

我想到的是以下内容(当然,下面的内容无法编译):

<TextBlock Text="Number of Fans: {Binding Artist.Fans.Count}"></TextBlock>

最佳答案

如果您使用的是 .Net 3.5 SP1,则有

<TextBlock Text="{Binding Path=Artist.Fans.Count, 
                 StringFormat='Number of Fans: {0}'}" />

关于wpf - 在 TextBlock 中使用绑定(bind)硬编码文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/789222/

相关文章:

c# - 如何在 WPF 中与 Width ="150*"相反?

c# - C# 中的 TreeView.Nodes[int].Name 在哪里?

c# - 移动 MainWindow.xaml

wpf - 公开依赖项属性

wpf - 绑定(bind)到带有可点击链接的列表框

wpf - EntityFramework EntityState 和数据绑定(bind)以及 INotifyPropertyChanged

c# - Prism.Unity.Wpf问题: UnityServiceLocatorAdapter is missing after update

wpf - 如何在列表框中获得垂直滚动条?

wpf - 自定义 UIElement 是否可以实现 IList<UIElement> 并直接分配子项(在 XAML 中)?

c# - 点击 ListView 项目上的手势