这是在派生的控件隐藏属性的方式?
Is this the way to hide properties in derived controls?
公共类NewButton:按钮
...
[Browsable ( false )]
public new ContentAlignment TextAlign { get; set; }
另外这个隐藏在设计师的属性窗口中的属性,但我怎么能还躲在code中的财产?
Also this hides the property in the Properties window in the designer but how can I also hide the property in code?
从code,你可以做到这一点,以隐藏它,也许是最接近使它成为一个痛苦的直接调用 - 注意,隐藏的,即使它是可调用,并没有这将工作过去投:
From code, the closest you can do it to hide it, and perhaps make it a pain to call directly - note that even when hidden it is callable, and none of this will work past a cast:
// about the closest you can do, but not really an answer
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
[Obsolete("just cast me to avoid all this hiding...", true)]
public new ContentAlignment TextAlign { get; set; }
就个人而言,我不会理会。这是不稳健(只投)。
Personally, I wouldn't bother. It isn't robust (just cast).