Tiberiu Ana
Tiberiu Ana

Reputation: 3663

Databind InkCanvas Children

In a WPF application I have an ObservableCollection of objects (areas on an image) that I want to display and edit (size and position) at runtime.

I would like to use an InkCanvas in Select mode with Rectangles representing my objects, but it doesn't seem to directly support data binding.

Is it possible to somehow bind the Children collection of an InkCanvas to an ObservableCollection?

Upvotes: 2

Views: 838

Answers (1)

Markus Hütter
Markus Hütter

Reputation: 7906

Have you tried using a ItemsControl with a Canvas set as ItemsControl.ItemsPanel? Then you can bind the ItemsSource property to your ObservableCollection. You can then use a ItemsControl.ItemsTemplate to bind a property of an item to the Canvas.Left (Right) Properties for absolute placement.

Upvotes: 1

Related Questions