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

Commented Unassigned: PropertyGrid.EditorDefinitions Broken [20120]

$
0
0
Not sure how this hasn't been noticed, but EditorDefinitions no longer work in 2.0. To reproduce, take the following code and stick it in a project:

__MainWindow.xaml__:
```
<Window x:Class="PropertyGridTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
Title="PropertyGrid Test">
<xctk:PropertyGrid x:Name="propertyGrid">
<xctk:PropertyGrid.EditorDefinitions>
<xctk:EditorDefinition TargetType="{x:Type sys:String}">
<xctk:EditorDefinition.EditorTemplate>
<DataTemplate>
<Border Background="Red">
<TextBlock>Here!</TextBlock>
</Border>
</DataTemplate>
</xctk:EditorDefinition.EditorTemplate>
</xctk:EditorDefinition>
</xctk:PropertyGrid.EditorDefinitions>
</xctk:PropertyGrid>
</Window>
```
__MainWindow.xaml.cs__:
```
using System.Windows;

namespace PropertyGridTest
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();

this.propertyGrid.SelectedObject = new Data();
}
}

public class Data
{
public string Name
{
get;
set;
}

public int Age
{
get;
set;
}
}
}
```
Then install 1.9.0:
```
Install-Package Extended.Wpf.Toolkit -Version 1.9.0
```
Run this and you will see a red border for the name entry, as expected. Now do this:
```
Uninstall-Package Extended.Wpf.Toolkit
Install-Package Extended.Wpf.Toolkit -Version 2.0.0
```
Run this again and you won't see the custom editor.
Comments: ** Comment from web user: BoucherS **

Hi,

We are sorry for this bug present in v2.0 of the Extended Toolkit.

But please notice that the "EditorDefinition" is an obsolete class since v2.0. If you still want to use it, you will have to add the "PropertiesDefinitions" like this :
```
<xctk:PropertyGrid.EditorDefinitions>
<xctk:EditorDefinition TargetType="{x:Type sys:String}" >
<xctk:EditorDefinition.PropertiesDefinitions>
<xctk:PropertyDefinition Name="Name" />
</xctk:EditorDefinition.PropertiesDefinitions>
<xctk:EditorDefinition.EditorTemplate>
<DataTemplate>
<Border Background="Red">
<TextBlock>Here!</TextBlock>
</Border>
</DataTemplate>
</xctk:EditorDefinition.EditorTemplate>
</xctk:EditorDefinition>
</xctk:PropertyGrid.EditorDefinitions>
```

The new way to use the "PropertyGrid.EditorDefinitions" (since v2.0) is the following :
```
<xctk:PropertyGrid.EditorDefinitions>
<xctk:EditorTemplateDefinition TargetProperties="{x:Type sys:String}">
<xctk:EditorTemplateDefinition.EditingTemplate>
<DataTemplate>
<Border Background="Red">
<TextBlock>Here!</TextBlock>
</Border>
</DataTemplate>
</xctk:EditorTemplateDefinition.EditingTemplate>
</xctk:EditorTemplateDefinition>
</xctk:PropertyGrid.EditorDefinitions>
```

Thank you for your cooperation.


Viewing all articles
Browse latest Browse all 4964

Trending Articles



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