I’m trying to learn wpf and in the process I’m basically trying to load a series of paths and draw them. I have several test “files” that contain certain samples of different geometry types. The “files” each have a different number of shapes.
What is the best way to load these files into a WPF application. I obviously don’t want to create individual paths in the XAML and so there is a better way, I just don’t know it. I’d still like the shapes to be hit-testable for example. I don’t want to just do a union and convert the multiple shapes to a single set of shapes.
I’m doing this in C# 4.0.
EDIT: I’ve basically just serialized the coordinates of various polygons to text files. I then create Paths from these text files. If I have a list containing 3 polygons, how do I render them without explicitly creating 3 paths in the XAML file?
you should read them in (say from a file) and use the
XamlReaderto create concrete instances of them. you can store them in anObservableCollection, and then bind said collection to anItemsControlwhere you have specified the panel as aCanvas.