Quantcast
Channel: Extended WPF Toolkit™ Community Edition
Viewing all articles
Browse latest Browse all 4964

Commented Unassigned: EditorTemplateDefinition of PropertyGrid for readonly property is not work on v2.2.1 Community Edition. [21089]

$
0
0
Hello.

I found that `PropertyGrid.EditorDefinitions` of some properties was not work on v2.2.1 Community Edition.
Rows for those properties show `toString` text simply.
Those properties don't have setter. (return object, and bind to the object's property in `EditorTemplateDefinition.EditingTemplate` )

I have used `EditorTemplateDefinition` as follow:

```xaml
<xctk:EditorTemplateDefinition>
<xctk:EditorTemplateDefinition.TargetProperties>
<xctk:TargetPropertyType Type="my:CalculatorUpDownViewModel" />
</xctk:EditorTemplateDefinition.TargetProperties>

<xctk:EditorTemplateDefinition.EditingTemplate>
<DataTemplate DataType="xctk:PropertyItem">
<xctk:CalculatorUpDown
Value ="{Binding Value.Value}"
Minimum ="{Binding Value.Minimum}"
Maximum ="{Binding Value.Maximum}"
Increment ="{Binding Value.Increment}"
IsEnabled ="{Binding Value.IsEnabled}"
FormatString="{Binding Value.FormatString}"
/>
</DataTemplate>
</xctk:EditorTemplateDefinition.EditingTemplate>
</xctk:EditorTemplateDefinition>
```

```cs
class MyViewModel {
[DisplayName("DisplayName")]
public CalculatorUpDownViewModel MyProperty
{
get { return this.myProperty; }
// set { }
}
...
}
```

It gets correct working again if I add empty setter into the property.
I think that `EditorTemplateDefinition` should work even if the model's property hasn't have setter.
Actually it had worked until v2.2.0 Community Edition.

Thanks.
Comments: ** Comment from web user: BoucherS **

Hi,

Based on this discussion : https://wpftoolkit.codeplex.com/discussions/546988,
if someone is using a one of these combination as attributes on a property :
-ItemsSourceAttribute and ReadOnlyAttribute(true)
-EditorAttribute and ReadOnlyAttribute(true)
the ReadOnly was not applied on the property in the PropertyGrid.

With the fix in v2.2.1, this issue doesn't happens anymore.

On the other hand, you have the problem you found : a property without a setter won't use its EditingTemplate. This is because it is a readOnly property : no setter. So to be able to use any kind of editor, the property needs to have a setter or else it is readonly by default.

I think it is not a normal behavior to have a property with only a getter and define its editingTemplate in XAML.


Viewing all articles
Browse latest Browse all 4964


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>