editors:DoubleEditBox with ComboBoxValueTemplateKey style

Editors for WPF Forum

Posted 5 years ago by Daniel Constantin - ModuleWorks GmbH
Version: 16.1.0634
Avatar

Hello,

How can I use the propgrideditors:DoublePropertyEditor inside a property grid for a double value ?

I tried with:

<propgrid:PropertyEditorsModifier x:Key="{x:Static propgrid:BuiltinEditors.PropertyEditorsModifierKey}">
  <propgrid:PropertyEditorsModifierActionAdd>
    <propgrideditors:DoublePropertyEditor PropertyType="{x:Type system:Double}"/>
  </propgrid:PropertyEditorsModifierActionAdd>
</propgrid:PropertyEditorsModifier>

inside the resources and also with:

<propgrid:PropertyGrid.PropertyEditors>
  <propgrideditors:DoublePropertyEditor SpinnerVisibility="Visible" PropertyType="{x:Type system:Double}"/>
</propgrid:PropertyGrid.PropertyEditors>

but I could not make it work.

And also if I want to have a more complex PropertyGridCategoryItem with lets say 2 comboboxes, can I find somewhere the property grid styles for comboboxes, buttons, etc or I need to write the styles myself ?

Any help is greatly appreciated.

Kind regards,

Daniel

Comments (21)

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Daniel,

Per the "PropertyGridIntegrationInterop" QuickStart, in the older 2016.1 API, either of those things should generally work.  Other than I don't believe you need to specify PropertyType on the since DoublePropertyEditor should do the Double recognition automatically.

As for the default styles, I believe your company has a WPF Studio license.  Whoever has access to the Actipro account can log in and download the default styles/templates from there.  The default styles for the property editors are in the PropertyGrid folder hierarchy within PropertyEditors.xaml. 

FYI, the newer PropertyGrid control found in the Grids product in the current version improved PropertyGrid performance by completely restructuring the internals of the control and making the DataTemplates used for property editors much simpler.


Actipro Software Support

Posted 5 years ago by Daniel Constantin - ModuleWorks GmbH
Avatar

Hello!

We are in the process of updating our licenses so I am glad to hear that about the new property grid :)

An example with the new property grid having inside some property editors and maybe a custom one with more controls would save a lot of time for me so if you have one it would be great.

Kind regards,

Daniel

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Daniel,

In the new version, the PropertyGridCustomPropertyEditor QuickStart shows an implementation of two custom property editors.  

As for the DoublePropertyEditor, that all should work the same way in the new version too.


Actipro Software Support

Posted 5 years ago by Daniel Constantin - ModuleWorks GmbH
Avatar

Hello!

Also another thing which I need to do is  that I want to put a representation of a matrix inside a PropertyGridPropertyItem. So basically I need to add like a datagrid with double values and to be clear to add also x,y,z as column headers and the same x,y,z, as row headers.

Kind regards,

Daniel

Posted 5 years ago by Daniel Constantin - ModuleWorks GmbH
Avatar

I just found the custom property editor. I think it might work

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Daniel,

Yes, with a custom property editor, you could put any WPF controls in the property value area.  You certainly could add a DataGrid like UI that you have when this matrix property is detected.  The property editor lets you designate a DataTemplate where you put the controls in, and the DataContext passed to that DataTemplate is the IPropertyModel.  This makes it easy to bind your controls.


Actipro Software Support

Posted 5 years ago by Daniel Constantin - ModuleWorks GmbH
Avatar

Hi,

I have a data grid as thevalue template for a PropertyGridPropertyItem. the problem is that I cannot see the entire data grid. The PropertyGridPropertyItem vertical lenght seems to be somehow defined somewhere.

How can change the PropertyGridPropertyItem to contain larger controls?

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Daniel,

We don't define a height, so it should use the height of the content.  It could be that your data grid isn't measuring itself to be taller. 

For instance if I open our custom property editor sample and put a Height="100" on the root control in the property editor DataTemplate, I see that height at run-time fine.  Maybe try setting a Height on your data grid control.


Actipro Software Support

Posted 5 years ago by Daniel Constantin - ModuleWorks GmbH
Avatar

Hi,

I made a minor mistake related to the height and I manage to make it work.

I am curious..

Can I merge a name cell and a value cell for displaying my datagrid without losing space on the left side or if this does not work, to set the weight of the name cell to be '*' and the value cell to be '2*'. I am trying to make the value cell weight larger than the name cell.. maybe twice as large if it's possible.

Posted 5 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Daniel,

Merging cells is possible, but a bit tricky.  Basically each row in the PropertyGrid is represented by a PropertyGridItem "container".  The data context of the row and the cells that end up in the row is the IDataModel instance for that row's property/category/category editor. 

We have a PropertyGridItemStyleSelector instance in the PropertyGrid.ItemContainerStyleSelector property that basically chooses between three different Styles by default for PropertyGridItem.  One is for properties, one is for categories, and one is for category editors.

You could make a class that inherits PropertyGridItemStyleSelector and in its SelectStyle method, see if the "item" is an IPropertyModel for your data grid property.  If so, then have it return a custom Style for a PropertyGridItem that in its Template has a PropertyGridItemContentPanel that wraps the DataGrid.  The PropertyGridItemContentPanel ensures everything is indented properly per the nesting level.  Bind the DataGrid like you do in your current property editor DataTemplate.

On the other hand, if you want to change column sizes instead, those can be set on the PropertyGrid.Columns collection.  It should have two columns in it.  Both columns have various MinWidth, Width, and MaxWidth settings.  You'd have to alter those as you would like.


Actipro Software Support

Posted 5 years ago by Daniel Constantin - ModuleWorks GmbH
Avatar

Thanks a lot!!

Posted 4 years ago by Daniel Constantin - ModuleWorks GmbH
Avatar

Hello!

I updated my Actipro packages from v16 to v19.1 and I am searching a replacement for " RelativeSource={RelativeSource AncestorType={x:Type propgrid:IPropertyDataAccessor}} " to be able to bind data in the new property grid.

Kind regards,

Daniel

Answer - Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Daniel,

The property editor design was improved in the 2017.1 version.  The "Grids / Converting from Previous Versions / Converting to 2017.1" topic has a list of all breaking changes made in that design update.

IPropertyDataAccessor interface is now IPropertyModel, and slow FindAncestor bindings were all removed.  Now the IPropertyModel is the data context passed to the property editor DataTemplates.  So you bind directly to it with no RelativeSource needed.  It's much simpler and faster.


Actipro Software Support

Posted 4 years ago by Daniel Constantin - ModuleWorks GmbH
Avatar

Thank you!

I did found that mentioned topic and it's very useful. We are using alot the PropertyGrid.

The only down side I found it might be how it needs to specify the name of the category. (category/subcategory)

We are getting the names from resources so I might need to have a backing property for that category name.

Cant do something like Category="{x:Static res:Test.Category} + {x:Static res:Test.Subcategory}" in XAML.

Kind regards,

Daniel

Posted 4 years ago by Daniel Constantin - ModuleWorks GmbH
Avatar

And if you can tell me the replacement for DialogTextBoxPropertyEditor it would be great :)

Answer - Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Daniel,

If you want to have localizable text for the CategoryAttribute on a property, you can use DisplayAttribute instead.  We watch DisplayAttribute.GroupName and will use that as the category if CategoryAttribute isn't specified.  Microsoft made DisplayAttribute localizable.

Please see the "Supported Property Attributes" topic in the PropertyGrid documentation for more info.


Actipro Software Support

Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Also the last section in the "Property Editors" documentation topic talks about dialog property editors.


Actipro Software Support

Posted 4 years ago by Daniel Constantin - ModuleWorks GmbH
Avatar

How can I remove entirely the Misc category. i need a property to not be under a category but inside the same PropertyGrid there will be properties under categories.

Kind regards,

Daniel

Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hello,

If categorization is enabled then all properties will be in a category.  That being said, if you inherit our TypeDescriptorFactory class and override the CategorizeDataModels method, you can watch for the Misc category returned as one of the child models from the base implementation.  Then remove that item from the returned list and insert its children in place of it.


Actipro Software Support

Posted 4 years ago by Daniel Constantin - ModuleWorks GmbH
Avatar

Hello !

I removed the Misc category but I have a small problem. After doing it I lose the order of the IDataModels.

I hope there is another solution than indexing the DataModels.

My DataModels needs to be in a specific oder unfortunately.

Kind regards,
Daniel

Posted 4 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

Hi Daniel,

The factory's SortDataModels method is where sorting occurs.  But if you do your updates in CategorizeDataModels after calling the base CategorizeDataModels implementation (which calls SortDataModels), I would expect that the data models present themselves in the exact order you return them in from your CategorizeDataModels implementation.


Actipro Software Support

The latest build of this product (v24.1.2) was released 10 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.