Sometimes Dependency Properties piss me off

July 27, 2011 at 11:31 am Leave a comment

Generally speaking, I like the concept of dependency properties – the ability to attach data to something is very handly. However, I don’t like how this implemented. Lets put a side their syntax – even after writing 1000 of them, I can’t write 1001 time without looking to previous examples. The most worst thing is a combination of dependency properties and items control. As you know (and maybe not), items control generates containers for every (non UIElement) item in Items collection. Now, assume that item (it’s UIElement representation) has any attached properties defined (such as Canvas properties). The canvas will test its direct children, which are containers – which doesn’t have these properties defined.
Huston, we have a problem! How we suppose to define dependency properties on item, if we don’t know how these items will be used? If we use just a panel it will work, if we will have ItemsControl in the middle – it will not. So we have only two ugly options: first is in style of items container define these properties with binding to content; and second to generate our own containers – if possible – and during that process create necessary bindings.
I think dependency properties should expose ability to make them visible to whole visual tree. I mean, if parent doesn’t have a required property – test its children, and so on.

Advertisement

Entry filed under: WPF. Tags: , , .

Lecture 1: Windows graphical interfaces Lecture 2- Windows UI Frameworks and introduction to WPF

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed


Categories


Follow

Get every new post delivered to your Inbox.