Using MVVM to work with CheckBoxes in XamDataGrid

September 4, 2008

On my other blog, I published a way to put CheckBoxes into the XamDataGrid.  The interesting aspect of the implementation, in my opinion, is how it uses the Model-View-ViewModel pattern to maintain the check state of each CheckBox.  Since I put a CheckBox into the header area above the CheckBoxes in each row, I used a ViewModel object to encapsulate the logic that figures out what state the header CheckBox should have, and how to update the state of each row’s CheckBox.  It’s just another example of how great MVVM is when working with WPF.

Here’s a screenshot of that demo app:

You can read that blog post here.


Introduction to attached behaviors

August 30, 2008

I just published an article on CodeProject that introduces the popular technique of attached behaviors in WPF.  The demo app is an extension of the demo provided by my ‘Simplifying the WPF TreeView by Using the ViewModel Pattern‘ article.  The new article shows how you can attach a behavior to TreeViewItem so that it scrolls into view upon being selected by a ViewModel object.  If you’re interested, here’s the link:

http://www.codeproject.com/KB/WPF/AttachedBehaviors.aspx

Enjoy!


Article about CheckBoxes in a WPF TreeView

August 1, 2008

After much experimentation, prodding, and poking (and some help from Dr. WPF) I’ve found a great way to put CheckBox controls into TreeViewItems.  There are some subtle and irritating issues that I needed to figure out and work around, particularly related to keyboard navigation.  However, the deed is done and now you can read all about it here:

http://www.codeproject.com/KB/WPF/TreeViewWithCheckBoxes.aspx

At the end of the article, I point out a bug in the CheckBox control that is specific to the Aero theme.  :-\


Improvements made to my MVVM commanding solution

July 26, 2008

I woke up extra early this morning and just had to implement some enhancements to my recent MVVM commanding solution.  I took Bill‘s brilliant advice and made a concrete CommandSink class. That alone is a HUGE improvement!  I made a fix that allows the CommandSink attached property to work for elements in a template.  This is related to the timing issues Bill and I discussed, wherein there is no guarantee that my attached property will be invoked *after* an element’s command bindings are created and added to its CommandBindings property.  Also, I renamed RelayCommandBinding to CommandSinkBinding because I think that more accurately expresses the purpose of the class.

The article has been updated to explain the new features.  All of the important changes are in the How It Works section.  Also, the source code download was updated.  Here’s the link:

http://www.codeproject.com/KB/WPF/VMCommanding.aspx


Article about using routed commands with MVVM

July 24, 2008

I just published an article on CodeProject that discusses a technique which simplifies the use of routed commands in an MVVM architecture.  If you’re interested, here is the link:

http://www.codeproject.com/KB/WPF/VMCommanding.aspx


Fifty articles and going strong!

July 5, 2008

I published my fiftieth article on CodeProject today!  😀

When I wrote my first article, which I find rather embarrasing today, back in February 2003, I never imagined that I would write 49 more.  It took me about five and a half years to reach fifty articles, but that’s OK…it’s not a race!  If you are interested, you can see a listing of all my articles here.

I decided to do something special for my fiftieth article.  I won’t bother explaining it here, but trust me, it’s pretty cool (in my opinion)…

Here’s the link: http://www.codeproject.com/KB/WPF/SelectDetailLevels.aspx


My first article in MSDN Magazine

July 4, 2008

The July 2008 issue of Microsoft’s MSDN Magazine contains an article I wrote about WPF data binding. The article is called “Customize Data Display with Data Binding and WPF“.  It covers a wide range of data binding techniques that real applications use all the time, from working with hierarchical data sources to input validation.  It even has a Virtual Lab, so you can get your hands dirty with source code while reading the article.  I think the article turned out very well, and hope that you agree!

This is the first time I was paid to write about WPF, and, in the words of Lloyd Christmas, “I like it…I like it a lot!”  😀

Link: http://msdn.microsoft.com/en-us/magazine/cc700358.aspx


Catalogue of Artificial Inheritance Context Techniques

July 2, 2008

I spent my lunch break today publishing an article that I’ve been working on for a couple of days. It explains and shows examples of three techniques I have developed for creating an artificial inheritance context.  This is useful for binding elements that are not in an element tree to the elements in the tree. If you are interested in checking it out, read “Artificial Inheritance Contexts in WPF“.

Enjoy!


Persisting field widths in XamDataGrid

June 20, 2008

I have been writing a lot about XamDataGrid on my other blog recently.  My most recent post shows how to save and load the widths of columns/fields across runs of the application.  This is just a temporary solution that will eventually be replaced by built-in functionality in the control, but until then, at least we now have a way to do this with ease.  My implementation even supports saving/loading the width of fields when showing hierarchical data (i.e. multiple related tables in the same grid).  Enjoy!


Article about visualizing a binary rule system

June 1, 2008

I just published a different kind of WPF article than I typically create.  This one is called “Visualizing a Binary Rule System with WPF” and discusses an interesting data visualization app I made over the weekend.  If you want to check it out, here’s the link:

http://www.codeproject.com/KB/WPF/BinaryRuleSystem.aspx

By the way, the Podder Skinning Competition deadline is July 1st 2008, just one month away!  8)