如何绑定按钮名称内容? [英] How to bind button Name to Content?

查看:111
本文介绍了如何绑定按钮名称内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有按钮的列表:

  <Button Style="{DynamicResource DestinationButtonStyle}">
                    <TextBlock Text="{Binding FullName}"
                               Style="{DynamicResource DestinationStationTextBlockStyle}"
                               TextTrimming="CharacterEllipsis" />
                </Button>

我想按钮具有等于内容的文字名称。
是否有可能使这种结合?

I want buttons to have names equal to text of content. Is it possible to make this kind of binding?

推荐答案

报价从的 MSDN

数据绑定的名称在技术上是可行的,但是是一个非常罕见的情况,因为数据绑定名称不能作为财产的主要预期目的:提供code-背后的标识符连接点

Data binding a Name is technically possible, but is an extremely uncommon scenario because a data-bound Name cannot serve the main intended purpose of the property: to provide an identifier connection point for code-behind.

总之,控制绑定 Name属性是不可能的,不可取的。但是你可以使用附加的依赖属性,如:

In short, the Binding Name property for control is impossible and undesirable. But you can use the attached dependency property, like this:

<Button local:GiveName.Name="{Binding FullName}" ... />

或者你也可以使用标签按钮标签绑定的作品。

这篇关于如何绑定按钮名称内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆