Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hiding a property of a WPF control from the Designer (Visual Studio 2010)

Tags:

c#

wpf

I'm using Visual Studio 2010 and WPF.

I'm creating a new Control that inherits from ContentControl and I wanna hide the Content property so it will be invisible in the Properties window at design time.

I tried with

[Browsable(false)]

like we do in WinForms but it doesn't work.

Any idea about how to solve this?

Thank you.

like image 863
Michelle Avatar asked Nov 02 '11 19:11

Michelle


1 Answers

Michelle,

Your property needs to be set to public:

[Browsable(false)]
public new object Content
{
    get { return base.Content; }
    set { base.Content = value; }
}

Once you set it to public, it will hide from the properties window.

With Private:

enter image description here

With Public:

enter image description here

Thanks

like image 86
CodeLikeBeaker Avatar answered Oct 20 '22 00:10

CodeLikeBeaker