Im creating some items in my UI in the following way
Buttons.cs
[Browsable(true)]
[Display(Order = 1, Name = "Object1", GroupName = "Objects", ResourceType typeof(Resources.DisplayNames) , AutoGenerateField =false)]
public ButtonViewModel Button1{ get; set; }
[Browsable(true)]
[Display(Order = 2, Name = "Object2", GroupName = "Objects", ResourceType typeof(Resources.DisplayNames) , AutoGenerateField =false)]
public ButtonViewModel Button2{ get; set; }
//etc
What im trying to do is show or hide these UI elements based on some condition. I saw that if i set AutoGenerateField to true/false i get the desired result, is there some way to set that value true/false at runtime? (if its even possible)
Is there another way to do this alltogether? Like adding/removing the display attribute each time.
EDIT
PropertyGridView.xaml
<Grid>
<telerik:RadPropertyGrid telerik:StyleManager.Theme="Fluent"
x:Name="PropertyGrid"
IsGrouped="True"
Item="{Binding SelectedItem}"
PropertySetMode="Union"
RenderMode="Flat"
SortAndGroupButtonsVisibility="Collapsed">
</telerik:RadPropertyGrid>
</Grid>
PropertyGridViewModel.cs
public class PropertyGridViewModel : Screen, IPropertyGridViewModel, IHandle<ItemSelectionMessage>
{
private IEventAggregator _eventAggregator;
private IItem _item;
public PropertyGridViewModel(IEventAggregator eventAggregator)
{
_eventAggregator = eventAggregator;
}
protected override void OnActivate()
{
base.OnActivate();
_eventAggregator.Subscribe(this);
}
protected override void OnDeactivate(bool close)
{
base.OnDeactivate(close);
_eventAggregator.Unsubscribe(this);
}
public IItem SelectedItem
{
get
{
return _item;
}
set
{
_item = value;
NotifyOfPropertyChange(() => SelectedItem);
}
}
public void Handle(ItemSelectionMessage message)
{
SelectedItem = message.Item;
}
}
And the item that gets passed is Buttons.cs above.