How to getting other data into CustomPropertyEditor?

Grids for WPF Forum

Posted 9 years ago by jeff jarrell
Version: 9.1.0505
I need to get other objects (really a dictionary of object references) into my CustomPropertyEditor. I've tried to go up the VisualTree to get retrieve my object dictionary in my custom property editor to no avail. (It's available in my PropertyGrid container.) But it doesn't appear a CustomPropertyEditor is in the visual tree (VisualTreeHelper.GetParent returns null and I've tried it from the Loaded event).

I don't really want to setup the reference in each of my IDataAccessors. So how would I do this?


Comments (3)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Jeff,

You are correct, the PropertyEditors are not part of the visual tree as they are never displayed anywhere. The PropertyEditor is simply a mapping used by the PropertyGrid to associated a DataTemplate with one or more properties.

You will be able to get to your Dictionary from within the DataTemplate, as the controls in there will be in the visual tree (once per property that uses it). I'm assuming this is actually where you'd want to access the Dictionary from, but if not please let us know.

Actipro Software Support

Posted 9 years ago by jeff jarrell
This is my data template. The thing that is the thing called PropGrid:JoinEditor. It is a UserControl. It is from here that I have tried to use the VisualTreeHelper to drill up. Maybe something with it being in a popup. I have tried to get it from the CTOR and the Loaded events.

    <DataTemplate x:Key="joinPropertyEditor">
        <ComboBox x:Name="joinComboBox" OverridesDefaultStyle="True" HorizontalAlignment="Stretch" HorizontalContentAlignment="Right">
                        <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="20"/>
                                <TextBox x:Name="JoinNo" Grid.Column="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Text="{Binding ElementName=joinEditor, Path=ViewModel.SelectedJoin, Mode=TwoWay}"/>
                                <ToggleButton Grid.Column="1" Content="..." IsChecked="{Binding Path=IsDropDownOpen, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"/>
                        <Popup  Focusable="False"
                                IsOpen="{Binding Path=IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}"
                                PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}"

                                        PanelJoin="{Binding Value, RelativeSource={RelativeSource AncestorType={x:Type actPropGrid:IPropertyDataAccessor}}, Mode=TwoWay}" 

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Hi Jeff,

That is most likely your issue. You can use Mole to quickly view the visual and logical trees to see where they stop. In the above, everything but your JoinEditor (the content of the popup) would be in the same visual tree as the PropertyGrid.

You might be able to reference your Popup element in your binding (such as {Binding Value, ElementName=PART_Popup, RelativeSource...}). But I'm not 100% sure.

Actipro Software Support

The latest build of this product (v2018.1 build 0675) was released 13 days ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.