【问题标题】:Button Content as their Name按钮内容作为他们的名字
【发布时间】:2011-12-15 02:26:37
【问题描述】:

我的问题完全与 XAML 相关,与代码无关。

WPF 按钮内容能否与其名称相同。

一种方法是

<Button Name="button1" Content="button1">

但是我有 250 个这样的按钮,更改按钮名称和内容就像更改 500 个位置一样。那么有没有一种方法可以让我只更改按钮名称和内容反映该值。

<Button Name = "button1" Content ={??????}>

【问题讨论】:

    标签: wpf xaml button wpf-controls


    【解决方案1】:

    Data binding:

    Content="{Binding Name, RelativeSource={RelativeSource Self}}"
    

    (阅读参考资料,数据绑定是WPF不可或缺的一部分)

    【讨论】:

      猜你喜欢
      • 2015-05-07
      • 1970-01-01
      • 2023-03-14
      • 1970-01-01
      • 1970-01-01
      • 2016-09-06
      • 2013-10-28
      • 1970-01-01
      • 2016-10-15
      相关资源
      最近更新 更多