Title: WPF: Selectable usercontrol - How?
Tags: c#;wpf
Question: I’m new to C# and WPF and have a problem I hope you can help with.

I have a WPF application with a stackpanel to which I add usercontrols by code to display the information stored in an instance of a class. The user can create instances, and musty be able to edit and delete instances of the class by selecting the usercontrol. The usercontrol contains a canvas for making a simple sketch as part of the information stored in the instance.

My problem is: How do I make the usercontrol selectable, so that the user can select an instance for editing or deleting, and so that I can address the canvas by code in a particular instance?

I hope you can help me.

/Morny

Comment: Put the UserControl in the ItemTemplate of a ListBox. Start reading here: [Data Templating Overview](https://msdn.microsoft.com/en-us/library/ms742521.aspx).

Comment: Could you show some code?



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2015:00:03/16/15', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<c#><wpf>', 'Title': 'WPF: Selectable usercontrol - How?', 'ViewCount': 370, 'id': 29078806, 'user_AboutMe': None, 'user_AccountId': 5947592.0, 'user_DisplayName': 'Morny', 'user_Reputation': 61.0, 'user_Views': 14.0, 'user_id': 4676662.0}}