Hi,
I have a PropertyGrid.
This PropertyGrid displays the a nested class called "Layer". From this Class I would only display the Value of the "Name" property and I don't want the user can type text in the value field.
Now I want to change this to a ComboBox which is bound to a property AllLayers, to let the user select another Layer.
Guess what - I didn't get it working.
XAML<dxprg:PropertyDefinition Path="*.ContextLayer" ContentTemplate="{StaticResource LayerNameTemplate}" AllowInstanceInitializer="False">
<dxprg:PropertyDefinition.EditSettings>
<dxe:ComboBoxEditSettings ItemsSource="{Binding AllLayers}" />
</dxprg:PropertyDefinition.EditSettings>
</dxprg:PropertyDefinition>
XAML<DataTemplate x:Key="LayerNameTemplate" DataType="{x:Type classes:Layer}">
<dxprg:CellEditorPresenter Path="Name"/>
</DataTemplate>
C#public List<Layer> AllLayers
{
get { return GetProperty(() => AllLayers); }
set { SetProperty(() => AllLayers, value); }
}
I made some progress…
<dxprg:PropertyDefinition Path="*.ContextLayer">
<dxprg:PropertyDefinition.EditSettings>
<dxe:ComboBoxEditSettings ItemsSource="{Binding AllLayers}" DisplayMember="Name" IsTextEditable="False" />
</dxprg:PropertyDefinition.EditSettings>
</dxprg:PropertyDefinition>
But now I have a "Layer" entry in the RowMenu. I thought I can disable this menuitem by setting AllowInstanceInitializer to false, but then I can't select any item from the combobox.
Hi Andreas,
Would you please clarify what menu item you mean?
Thanks,
Alexander
I made a little video
Hello Andreas,
Your approach with ComboBoxEditSettings in the previous comment is correct and should work. It would be great if you post your comment as an answer to allow other customers to find it more easily.
I've created a separate ticket for the issue with setting the AllowInstanceInitializer property to False on your behalf: A property of a complex type cannot be edited if the AllowInstanceInitializer property of the corresponding PropertyDefinition is set to False. Let's continue our discussion there.
Thanks,
Andrey