Following up the post on Custom controls in ViewModel aided views

The first article is found here and in the last section I said I would create a CustomControl that show data in a gantt chart; here it comes.

image

A very naïve model to hold the data.

Then a ViewModel that can show and create data defined by that model:

image

 

Then I hook up the newly created Gantt-wrapper that has this text to describe its requirements:

A list column with name TreeNodes.
Each TreeNode should have Column1 and Column2 to display in grid
TreeNodes can also have an association TimeItems; each TimeItem should have Start,Stop(DateTime), Text(string),Color(int)
TreeNodes can also have a association TreeNodes to sub TreeNodes; these tree nodes should also have Column1,2, and TimeItems

To allow for a TimeItem to move from one row to another add an Action column on TimeItem named MoveToNewRow, also declare viewmodel variable vNewRow of the type your class representing the TimeItem has
can then implement the move in the Action execute expression; vNewRow.SomeTimeItem.add(self)

We need to read and understand in order to make our ViewModel fit the need of the rather complex UI control.

If we follow these guidelines we get data shown in the control – bound by WPF-databinding :

image

We can do things like select and move, resize, switch rows, edit texts in the tree etc, etc.

The Gantt control also supports windows 8 gestures so now I can swipe back and forth (I  went out and got me a touch screen) and change my data without typing. Ler

This entry was posted in ViewModel, WECPOF. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.