How to getting other data into CustomPropertyEditor?

Grids for WPF Forum

Posted 9 years ago by jeff jarrell
Version: 9.1.0505
Avatar
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?

Thanks,
jeff

Comments (3)

Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
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
Avatar
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">
            <ComboBox.Template>
                <ControlTemplate>
                    <Grid>
                        <Border HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                            <Grid>
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="20"/>
                                </Grid.ColumnDefinitions>
                                <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}}"/>
                            </Grid>
                        </Border>
                        <Popup  Focusable="False"
                                AllowsTransparency="True"
                                IsOpen="{Binding Path=IsDropDownOpen, RelativeSource={RelativeSource TemplatedParent}}"
                                Placement="Bottom"
                                PopupAnimation="{DynamicResource {x:Static SystemParameters.ComboBoxPopupAnimationKey}}"
                                x:Name="PART_Popup">

                            <PropGrid:JoinEditor
                                        
                                        PanelJoin="{Binding Value, RelativeSource={RelativeSource AncestorType={x:Type actPropGrid:IPropertyDataAccessor}}, Mode=TwoWay}" 
                                        Background="White" 
                                        BorderBrush="Black" 
                                        BorderThickness="1" 
                                        x:Name="joinEditor"/>
                        </Popup>
                    </Grid>
                </ControlTemplate>
            </ComboBox.Template>
        </ComboBox>
    </DataTemplate>


Posted 9 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
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.