XamlParseException

Grids for WPF Forum

Posted 10 years ago by David Sherwood
Version: 9.2.0515
Platform: .NET 3.5
Environment: Windows 7 (64-bit)
Avatar
Getting the following error:
System.Windows.Markup.XamlParseException was unhandled
  Message="'TreeListViewRowPresenter' object cannot be added to 'Border'. Exception has been thrown by the target of an invocation.  Error at object 'ActiproSoftware.Windows.Controls.PropertyGrid.Primitives.TreeListViewRowPresenter' in markup file 'ActiproSoftware.PropertyGrid.Wpf30;v9.2.515.0;component/Themes/PropertyGrid/Common.xaml'."
This happens when I add the following to my property grid:

                                           <propgrid:PropertyGrid.ValueCellContainerStyle>
                                                <Style TargetType="TextBox" >
                                                    <Setter Property="TextWrapping" Value="Wrap" />
                                                    <Setter Property="MaxWidth" Value="400" />
                                                </Style>
                                            </propgrid:PropertyGrid.ValueCellContainerStyle>
As you can see, I'm trying to add text wrapping to my sting property value. Is not this the way to do it?

Comments (5)

Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi David,

No, that is not the correct way. The ValueCellContainerStyle allows you to style the overall cells of the value column, not the underlying editors. If you want to apply an implicit Style to all TextBoxes in a PropertyGrid, then you can move your Style to the PropertyGrid.Resources.

If you only want to customize the look of one property or property type, then you would need to use a custom property editor. The RectPropertyEditor in the Editors Integration (Custom) demo shows one way you can create a property editor and an associated DataTemplate. That example uses the EditorAttribute to tie the property editor to the property, but you can also use PropertyGrid.PropertyEditors or BuiltinEditors.PropertyEditors.

These two collections allow you tie a property editor to one or more properties by name, type, or both. The Editors Integration (Interop) demo shows how the PropertyEditors collections are used.


Actipro Software Support

Posted 10 years ago by David Sherwood
Avatar
Ok, I moved it to resources but the text is just truncated. I don't get multiple lines or even horizontal scroll bars even though I set these properties.
Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi David,

Sorry, our default property editors set MaxLines to 1. There's no way to override that, so you'd need to define a new property editors. You could use our default property editor as a basis and tweak it to your needs, which would allow you to remove the implicit Style. If you are a WPF Studio customer you can download the default Styles/Templates from our web site (you'd want to look in the PropertyGrid styles in the file PropertyEditors.xaml). If you purchased PropertyGrid separately, then if you send an email to our support address we can provide the appropriate files.

If you want to apply this change to all properties, you would copy and tweak the DynamicValueTemplateKey DataTemplate. If you past it in your App or window resources, then all instances of PropertyGrid will pick up your changes.


Actipro Software Support

Posted 10 years ago by David Sherwood
Avatar
Thank for telling me about the default Styles. I didn't know you could download theses. I used the DynamicValueTemplateKey, removed the combo box and all of the triggers, bound Text property like one of the triggers, and removed MaxLines propery.
I question why the MaxLines property is in the template, since a TextBox normally works with one line. This is a lot work just to get rid of it.
Posted 10 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Hi David,

Glad you got it working. The TextBox does prevent the user from entering multiple lines by default, but if the property's text has embedded newlines then it would display multiple lines. Depending on the size of the text and number of lines, this could make the PropertyGrid unusable (due to one row being extremely large). We also tried to duplicate what the native WinForms PropertyGrid does, but still offer the ability to change the behavior with custom property editors.

Regardless, I've marked down a TODO item to add multi-line versions of our editors in the future. This would allow you to set your own MaxLines/AcceptsReturn etc.


Actipro Software Support

The latest build of this product (v2019.1 build 0683) was released 2 months ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.