In WPF project, references only used in xaml is not copied to bin folder even with CopyLocal
set to true, as complained in this post. With MVVM pattern, it is common that 3rd party controls are used with no code-behind references at all.
Inspired by this post, I am using the workaround below. It's easy enough, however, one has to manually maintain the variable list in sync with those actually used in the XAML files across the project, which are subject to constant changes. My question is whether there is a real solution or a better workaround? (I am aware of the idea of using post-build script, which IMHO is less discover-able and more vulnerable to changes.)
internal static class BuildTricker
{
private static readonly RadTreeView radTreeView;
static BuildTricker()
{
// Set and get once to avoid compiler optimization.
radTreeView = null;
if (radTreeView != null)
{
throw new InvalidOperationException("This should never happen.");
}
}
}
<Private>
tag is the implementation ofCopyLocal
property. – Termination