How can you tell at run time if a style applied to an object is the default style?
2 answers
It looks like you can do it like this:
DependencyPropertyHelper.GetValueSource(
someControl, FrameworkElement.StyleProperty).BaseValueSource
== BaseValueSource.Default;
You can wrap it in an extension way like this:
static public bool HasDefaultStyle(this FrameworkElement item)
{
return DependencyPropertyHelper.GetValueSource(
item, FrameworkElement.StyleProperty).BaseValueSource
== BaseValueSource.Default;
}
Then you can just call someControl.HasDefaultStyle()
.
Also, check out this article: Default Templates in WPF
+3
source to share