I need to determine if a control on my window has a specific dependency property declared. Here is an example of a button with the DP DemandRole. That DP can be declared for various control types, not only buttons. I'm trying to enumerate all controls on a window and return only those which have the DP DemandRole declared.
<Button x:Name="_reset"
sec:SecurityAction.DemandRole="Admin,Engineer,SuperUser,Technician,Supervisor"
Content="_Reset"
Visibility="Visible"
Command="{Binding ResetPasswordCommand}" />
I've can get Dependency Properties for a specific type, but that only returns properties for the type and does contain the DP I have defined for the controls.
static IEnumerable<FieldInfo> GetDependencyProperties(Type type)
{
var dependencyProperties = type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static)
.Where(p => p.FieldType.Equals(typeof(DependencyProperty)));
return dependencyProperties;
}
Any idea how I can get all DPs on a specific instance of a control?
Thanks,
Lance