Reputation:
Take my navigationItem usercontrol:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Uboldi.Helpers;
namespace Uboldi
{
public partial class NavigationItem : UserControl
{
public bool IsSelected { get; set; }
public string Text { get; set; }
public NavigationItem()
{
InitializeComponent();
RefreshDisplay();
}
private void RefreshDisplay()
{
if (IsSelected)
this.BackColor = CustomizationHelper.GetSecondaryColor();
else
this.BackColor = CustomizationHelper.GetPrimaryColor();
}
}
}
In Visual Studio I can see the IsSelected property, but not the Text property.
Any reason why?
Upvotes: 2
Views: 2248
Reputation: 942518
The Text property is inherited from UserControl. Where it is hidden, a user control has no meaningful way of of showing text. You have to inherit it again and turn all the attributes off that make it hidden. Like this:
[Browsable(true)]
[EditorBrowsable(EditorBrowsableState.Always)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
[Bindable(true)]
public override string Text {
get { return base.Text; }
set { base.Text = value; }
}
Upvotes: 3
Reputation: 48730
You need to mark the properties you want visible in the design time properties list with a BrowsableAttribute.
[Browsable(true)]
public bool Text { get; set; }
At a guess, the IsSelected property was inherited, and had this attribute set. I'm probably off, because I think the compiler would warn you that you were shadowing an inherited property if this was the case.
Upvotes: 1