July WPF Guru - Magnus brings us "Binding the IsChecked Property of a CheckBox to Several Other CheckBoxes"

It's time for another July TechNet Guru winner!

Congratulations to Magnus (MM8), our WPF Guru winner for July! See the TechNet Guru Contributions for July 2013.


Magnus' Blog: http://blog.magnusmontin.net/


Here is the gold-medal-winning article:

WPF/MVVM: Binding the IsChecked Property of a CheckBox to Several Other CheckBoxes


Now let's look at all the winning articles: 

Guru Award  WPF Technical Guru - July 2013  

Gold Award Winner


Magnus MM8 (Magnus Montin) WPF/MVVM: Binding the IsChecked property of a CheckBox to several other CheckBoxes AN: "Very detailed, nice images, excellent explanations" Ed Price: "Strong introduction and good explanations for each code snippet. Terrific!"

Silver Award Winner


XAML guy (Peter Laker) WPF Data, Item and Control Templates - Minimum code, maximum awesome AN: "Love the animated gif/video. Great introduction to WPF" Ed Price: "Good workflow and the animated GIF is great! The introduction could use more of an explanation of the scenarios and problems that the code solves. Great article!"

Bronze Award Winner


Gaurav Khanna Editable Button in WPF AN: "Nice code dump. Would like a little more explanation." Ed Price: "It's a good solution, but it would be better to break up the code with explanations and to describe the various concepts more."


Only three entries and all three are winners for July. WPF is a popular technology, so hopefully we will see more entrants soon.




And here's an excerpt from the article:



Defining a GroupStyle

To define the appearance of each group of countries, i.e. a continent, you specify a GroupStyle and add it to the GroupStyle property of the ItemsControl. This property contains a collection of GroupStyle objects that determine the group style for each level of groups (to support cases where you may have multiple levels of grouping) with the entry at index 0 describing the top-level group, the entry at index 1 describing the next level and so on.

The GroupStyle class has a ContainerStyle property of type System.Windows.Style that is used to determine the style for each group item in the same level. You can completely redefine the look and feel of a group item by specifying a style that sets the Template property to a custom ControlTemplate. In the sample markup below, an Expander control with a three-state CheckBox control and a TextBlock for displaying the name of the group in its header are used. The ItemsPresenter element is used within a template to specify where the ItemsPanel with the bound objects, i.e. the Country objects in this case, defined by the ItemsControl is to be added in the control’s visual tree.

<``ItemsControlItemsSource``=``"{Binding Source={StaticResource countries}}"... >





<``StyleTargetType``=``"{x:Type GroupItem}"``>



<``ControlTemplateTargetType``=``"{x:Type GroupItem}"``>





<``TextBlockText``=``"{Binding Name}"


Margin``=``"2 0 0 0"/>















Note that the style will be applied to elements of type System.Windows.Controls.GroupItem and the DataContext of each of these group elements is a MS.Internal.Data.CollectionViewGroupInternal object which you can see if you use the WPF Visualizer – a tool that lets you search and drill down the visual tree produced by WPF – when debugging the application in Visual Studio:






Read the rest here:

WPF/MVVM: Binding the IsChecked Property of a CheckBox to Several Other CheckBoxes


Thanks to Magnus (MM8) for your great contribution to the TechNet Guru contest! You can read about all the July winners here: TechNet Guru Awards - July 2013


Also, for the August Guru competition, see TechNet Guru Contributions - August 2013.  


Magnus won a Bronze Medal in June and came back to win the Gold in July! Please join me in congratulating Magnus on this well-deserved win!


Are you a Wiki Ninja? http://technet.com/wiki

    - Ninja Ed