开发者

Hide property from inherited silverlight control

开发者 https://www.devze.com 2023-02-15 17:20 出处:网络
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 virtua

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

精彩评论

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