Property Visibility issue

Grids for WPF Forum

Posted 15 years ago by Maulik Goradiya
Version: 4.5.0487
Avatar
Hi,

I am not able to make property item to hide/collapse state. Please find below code.

[Requirement:
- Property control must be populated from code-behind/dynamically using propGrid.Properties.Add(...) method.]

PropertyGridPropertyItem item = new PropertyGridPropertyItem();
item.DisplayName = "Simple Propety";
item.Category = "General Properties";
item.Visibility = Visibility.Collapsed; // or Visibility.Hidden
propGrid.Properties.Add(item as IPropertyDataAccessor);

Q - 1: When above code executed it display "Sample Property" in property control EVEN IF Visibility set to Collapsed/Hidden. What can I do?

LATER I need to set property's Visibility to "Visible" when some event occures or condition satisfied. So, I have to add it.

Comments (4)

Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Maulik,

This isn't currently supported. The PropertyGridPropertyItem is just used as a "data layer" object, and all presentation is actually performed by PropertyGridDataAccessorItem. You might be able to apply an implicit style to PropertyGridDataAccessorItem, by including this in your app/window resources:
<Style TargetType="{x:Type propgrid:PropertyGridDataAccessorItem}">
   <Setter Property="Visibility" Value="{Binding Visbility}" />
</Style>
But we haven't tested this, and would not work for properties obtained from SelectedObject(s).


Actipro Software Support

Posted 15 years ago by Balaram Barange
Avatar
Hi,

I also needed to do the same could you please tell us when can we get this feature supported as this is very essential for our property pages implementation. Could you please provide some more line of codes to get the workaround done. Applying style to PropertyGridDataAccessorItem and relatted piece of code.

Thanks and Regards,
Balaram
Posted 15 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi Balaram,

We will look into this more after we get WPF Studio 5.0 released. I cannot give you any timeframes as to when it would be included.

The workaround above actually has a mispelling in it (which is corrected below), but to use it you can simply include the Style in the PropertyGrid resources, the resouces of a parent control of the PropertyGrid, or your application resources. The latter two are useful in that they can encompass more than one instance of the PropertyGrid.

For a single PropertyGrid, this works:
<propgrid:PropertyGrid ...>
    <propgrid:PropertyGrid.Resources>
        <Style TargetType="{x:Type propgrid:PropertyGridDataAccessorItem}">
            <Setter Property="Visibility" Value="{Binding Visibility}" />
        </Style>
    </propgrid:PropertyGrid.Resources>
    ...
</propgrid:PropertyGrid>


Actipro Software Support

Posted 15 years ago by Balaram Barange
Avatar
Thanks Team. Its working.
The latest build of this product (v24.1.2) was released 2 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.