Friday, July 8, 2011

WPF/Silverlight Binding Using Flags Class - CodeProject

Silverlight LogoImage via WikipediaIntroduction to article

A flag enumeration is a very useful tool in programming. However, it is not straightforward to use flags in binding. Somehow or another, the particular flag has to be specified. This is possible using the binding "parameter". With this information, it is quite straightforward to convert for the View, but the problem is converting back. You would normally be binding to a checkbox and this value is either true or false (tri-state does not make sense). When converting back, there is no information about the state of the other flags. Without this information, it is not possible to update the flags value in the View-Model. This is one of the main reasons a special class is needed to support binding a set of flags to a View. Once there is an implementation to support flags in both WPF and Silverlight, implementations can be much cleaner.

WPF/Silverlight Binding Using Flags Class - CodeProject
Enhanced by Zemanta

No comments: