WPF x:Shared

A customized DataTemplate defined in xaml and need to be run-time loaded twice. By default, it is shared, which means any given resource request always returns the same instance. For my case, loading the resource by calling FindResource in the code behind works fine for the first time, and got an exception for the second time.

Fixing it by specifying the resource non shared. x:Shared=”false”

MSDN x:Shared Attribute