Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine if a WPF DependencyProperty value is inherited

Does anyone know how to determine if the value of a WPF property is inherited? In particular, I'm trying to determine if the DataContext of a FrameworkElement was inherited from the parent or set directly on the element itself.

like image 737
Michael Hewitt Avatar asked Apr 30 '09 20:04

Michael Hewitt


1 Answers

DependencyPropertyHelper.GetValueSource will give you a ValueSource, which includes a property for retrieving the BaseValueSource. The BaseValueSource enumeration tells you where the DependencyProperty is getting its value from, such as inherited from parent, set via a style or set locally.

like image 72
Kent Boogaart Avatar answered Sep 25 '22 08:09

Kent Boogaart