Home » » Does a class have a Dependency Property or not?

Does a class have a Dependency Property or not?

Dependency Properties are pretty darn important in WPF. Sometimes when you are messing with a class, you may want to know if that class has a Dependency Property associated to it. But how?

Like this:

var _PropertyName = "MyClass.MyProp";
var _Markup = System.Windows.Markup.Primitives.MarkupWriter.GetMarkupObjectFor(_MyObject);
var _Properties = _Markup.Properties.Where(x => x.DependencyProperty != null);
var _Property = _Properties.Where(x => x.Name == _PropertyName).FirstOrDefault();
if (_Property != null) { /* has property! */ }


0 comments:

Post a Comment

Popular Posts

Powered by Blogger.
.comment-content a {display: none;}