views:

118

answers:

0

I'm trying to createa time-tracking application in WPF. The user is supposed to draw elements that represent a timespan (timespan = bar) onto a Canvas. Now, exisiting bars are added when they are databound to a collection (each collection item contains the width and left position of the bar on the Canvas).

The 'bar' Usercontrol has a dependency property called "ProjectProperty" which takes care of drawing and positioning the bar on the Canvas.

But what needs to happen when the user draws a new bar on the Canvas? It has to somehow be databound, but at what point in time does this need to happen, and how would I do that?

I understand that each of the 'bar' UserControls on the Canvas is databound, simply because they already exist in the datasource.

Say the user starts drawing the bar on mousedown and finishes on mouseup, do I have to programtically add its left position and width to the bound datasource? If not, how else would the datasource be updated?

Thanks!