Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
560
EditorRemoved removes DataContext
posted

Hi,

In the TemplateColumnContentProvider class you recently modified the EditorRemoved method and added the following lines:

if (this._editor != null)

    this._editor.DataContext = null;

This fails in the following scenario:

We have a TemplateColumn with a EditorTemplate which contains a ComboBox. The ComboBox' ItemsSource is set using binding to the DataContext (as is the SelectedItem, which is two-way bound). When your code removes the DataContext in the EditorRemoved method, the ItemsSource is set to null (because it was bound to the DataContext) and as a result, the SelectedItem is set to null by the ComboBox (which is logical, because the ItemsSource is null). This all results in the problem that you can select what you want in edit mode, if you exit the cell, the resulting selection will always be null.

We are lucky that we bought your source code, so we could remove the lines. Now it works again... I guess the reason you added this lines is because the DataContext possibly is held too long, but this clearly is not the solution.

Arjen