开发者

Hide property from inherited silverlight control

I am trying to hide a property from Intellisense for the Text property of the TextBox control.

I tried the following, but I get a compile error complaining that the Text property is not set as virtual in the base class. I am not trying to remove the property, just hide it from Intellisense. Any ideas?

public class MyTextBox:TextBox
{

   [EditorBrowsable(EditorBrowsableState.Never)]     
   [Browsable(false)]
   public override string Text
   {开发者_StackOverflow
      get
      {
         return base.Text;
      }
      set
      {
        base.Text = value;
      }
   }

}


YOu can use new keyword to hide it if its not virtual.

Like this:

public class MyTextBox:TextBox
{
   [EditorBrowsable(EditorBrowsableState.Never)]     
   [Browsable(false)]
    public new string Text
    {
      get
      {
         return base.Text;
      }
      set
      {
        base.Text = value;
      }
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜