I have a DataTemplateSelector which is applied to a DataGridTemplateColumn.
It is correctly providing me with a DataTemplate that varies depending on certain information in my DataRow (in other columns).
So far so good.
However, when I now alter data in my grid which would cause a different DataTemplate to be chosen by the selector for that column it does NOT automatically show this new DataTemplate.
I read in Pro WPF in C# 2008 by Matthew MacDonald (Apress) page 564 that this is known issue and the only way around is to release the Selector and reapply this which would be very slow when there are many records in my table.
Has anyone found a way around this or maybe in .NET4 there is a new feature that combats this issue?
Thanks
Marcel
One solution is to put a ContentPresenter inside the cell. That way when the content changes the ContentPresenter will request the template from the selector again. eg:
and code behind:
Edit: I have removed my previous answer which was to use a converter instead of a selector. That did work but I think this is a better answer.