such as:
public class RoleProperties : NotifiedClass
{
private string _name;
private bool _canUpload;
private bool _canPublish;
private bool _canDelete;
private bool _canEdit;
private bool _canPreview;
public string Name
{
get { return _name; }
set { _name = value;
OnPropertyChanged("Name");}
}
public bool CanUpload
{
get { return _canUpload; }
set { _canUpload = value; OnPropertyChanged("CanUpload"); }
}
public bool CanPublish
{
get { return _canPublish; }
set { _canPublish = value; OnPropertyChanged("CanPublish"); }
}
public bool CanDelete
{
get { return _canDelete; }
set { _canDelete = value; OnPropertyChanged("CanDelete"); }
}
public bool CanEdit
{
get { return _canEdit; }
set { _canEdit = value; OnPropertyChanged("CanEdit"); }
}
public bool CanPreview
{
get { return _canPreview; }
set { _canPreview = value; OnPropertyChanged("CanPreview"); }
}
}
7 Answers, 1 is accepted
Yes, there is. RadPropertyGrid supports the Browsable attribute. Here is an example that illustrates RadPropertyGrid support for several property attributes.
Greetings,
Ivan Ivanov
the Telerik team
here is where it does not work. i have my property grid declared as such:
<
telerik:RadPropertyGrid
Item
=
"{Binding Path=ActiveShow, ElementName=mainControl, Mode=TwoWay}"
SearchBoxVisibility
=
"Collapsed"
LabelColumnWidth
=
"75"
NestedPropertiesVisibility
=
"Visible"
DescriptionPanelVisibility
=
"Collapsed"
/>
ActiveShow is represented by a custom class like such:
private string name;
private string description;
private string aspectRatio;
private ObservableCollection<
Region
> regions;
public ShowTemplate()
{
regions = new ObservableCollection<
Region
>();
}
[DataMember]
[Display(Order=1)]
public string Name
{
get
{
return name;
}
set
{
name = value;
OnPropertyChanged("Name");
}
}
[DataMember]
[Display(Order = 2)]
public string Description
{
get
{
return description;
}
set
{
description = value;
OnPropertyChanged("Description");
}
}
[DataMember]
[Display(Order = 7)]
public string AspectRatio
{
get
{
return aspectRatio;
}
set
{
aspectRatio = value;
OnPropertyChanged("AspectRatio");
}
}
[DataMember]
[Display(Order = 8)]
public ObservableCollection<
Region
> Regions
{
get { return regions; }
set
{
regions = value;
OnPropertyChanged("Regions");
}
}
The problem becomes with the Regions property of this class. The region property is a collection of Regions defined as such:
public class Region : NotifiedClass
{
public Region()
{
playlists = new ObservableCollection<
Playlist
>();
}
private int id;
private string name;
private float height;
private float width;
private float canvasTop;
private float canvasLeft;
private int showID;
private string color;
private ObservableCollection<
Playlist
> playlists;
[Browsable(false)]
[DataMember]
public int ID
{
get
{
return id;
}
set
{
id = value;
OnPropertyChanged("ID");
}
}
[DataMember]
public string Name
{
get
{
return name;
}
set
{
name = value;
OnPropertyChanged("Name");
}
}
[DataMember]
public float Height
{
get
{
return height;
}
set
{
height = value;
OnPropertyChanged("Height");
}
}
[DataMember]
public float Width
{
get
{
return width;
}
set
{
width = value;
OnPropertyChanged("Width");
}
}
[DataMember]
[Display (Name = "Top")]
public float CanvasTop
{
get
{
return canvasTop;
}
set
{
canvasTop = value;
OnPropertyChanged("CanvasTop");
}
}
[DataMember]
[Display(Name = "Left")]
public float CanvasLeft
{
get
{
return canvasLeft;
}
set
{
canvasLeft = value;
OnPropertyChanged("CanvasLeft");
}
}
[DataMember]
public int ShowID
{
get
{
return showID;
}
set
{
showID = value;
OnPropertyChanged("ShowID");
}
}
[Browsable(false)]
[DataMember]
public string Color
{
get
{
return color;
}
set
{
color = value;
OnPropertyChanged("Color");
}
}
public ObservableCollection<
Playlist
> Playlists
{
get { return playlists; }
set
{
playlists = value;
OnPropertyChanged("Playlists");
}
}
}
the problem i have is not matter what set on region properties they always show in the property grid. A prime example being the Color property of Region. I dont want it to show but even with browsable(false) it still shows in the property grid. I have also tried setting Display(AutoGeneratedField=false) on these properties to no effect.
How do i get this to work save having to manually define the property Row Definitions in xaml?
We did have an issue with respecting Browsable attribute for nested properties. However, it has already been resolved in our internal builds. Please download the latest one and let me know whether you still have any problems.
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Actually, the fix has been available for a couple of weeks now. So, if you are working with our latest internal build (from this Monday - 30.04.2012), you should not get the undesired behavior. Do you still have some troubles ?
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
to start with in the property grid my property regions shows and is 'expandable' as expected. however it shows the object type beside it, this should be hidden.
When i expand regions it shows count 2 (again because its an observable collection, count should be hidden)
it then shows items and indicates it can expand but when i click on the plus nothing is there....
The fix I was referring to is the one with setting Browsable attribute for nested properties. Considering expanding the 'Item" property of the Regions - indeed I managed to reproduce it with our latest version. I will research the case and let you know once I could provide more information on it. As for the Count property - you can hide it as follows:
private void myPropertyGrid_AutoGeneratingPropertyDefinition(object sender, Telerik.Windows.Controls.Data.PropertyGrid.AutoGeneratingPropertyDefinitionEventArgs e)
{
if(e.PropertyDefinition.Binding.Path.Path == "Count")
{
e.Cancel = true;
}
}
Will that approach meet your requirements ?
All the best,
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>