简体   繁体   English

向WPF TextBox类添加额外的属性

[英]Adding an extra property to WPF TextBox class

I a trying to change the TextBox wpf control so that it would include an extra property (a string). 我试图更改TextBox wpf控件,使其包含一个额外的属性(字符串)。 Is it possible to change an existing control? 是否可以更改现有控件? Would it be possible to create a new control that inherits from TextBox? 是否可以创建一个继承自TextBox的新控件?

You cannot add an extra property to the TextBox control. 您不能向TextBox控件添加额外的属性。 You can however inherit from the TextBox control and make your own control. 但是,您可以从TextBox控件继承并制作自己的控件。 Add your extra properties in your custom control. 在您的自定义控件中添加您的其他属性。

Having said that, if you have a single property that you require, you can always use the Tag property for your custom requirements. 话虽如此,如果您只需要一个属性,则可以始终将Tag属性用于自定义要求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM