Wednesday, March 10, 2010

Binding AttachedProperty Based on SelectedItem in Xaml

Hi,

Today one of our WPF product customer raised a question about how to bind an attached property in XAML. I was wondered like what is the problem in it, and I just replied him immediately with below code.


But after his detailed reply for my post, came to know that his question was valid :). Because he wants to bind the attached property of custom ItemsControl using its items object without mentioning specific child object name whenever active item gets changed.

I just tried following code and its working perfectly without any event handler or converter in View Modal application.

Here is the solution.



Note that, ActiveItem should get updated whenever you select any item in itemscontrol. Just like SelectedItem property.

Thanks to the WPF team for providing powerful binding stuffs.

-Venugopal.

No comments:

Post a Comment