I'm using event to command explaind here: http://nerobrain.blogspot.nl/2012/01/wpf-events-to-command.html
I now try to add controls from codebehind, since I dynamically have to add them depending on data from db. How perform the same thing as below but from codebehind
How do I add the "local" part in codebehind?
Update:
This is the problem I'm trying to solve, I'll try to summerizes i shortly :)
The user is supposed to leave feedback after usage of the application.
The feedback information can consist of multiple questions that can either be
- single choice
- multiple choice.
So one FeedbackSet can have several FeedbackGroups that can either have single choice FeedbackCodes or multiple choice FeedbackCodes or have subgroups of FeedbackGroups/FeedbackCodes
- A single choice will result in a ComboBox
- A multiple choice will result in a ListBox
- A Subgroup will generate a TreeView
The model(shortend code):
public class FeedbackSet
{
public int Id{get;set;}
public string Name{get;set}
public List<FeedbackGroup> Groups{get;set;}
}
public class FeedbackGroup
{
public int Id{get;set;}
public string Name{get;set;}
public FeedbackGroupType Type
public List<FeedbackGroup> Groups{get;set;}
public List<FeedbackCode> Codes{get;set;}
}
public class FeedbackCode
{
public int Id{get;set;}
public string Name{get;set}
}
public enum FeedbackGroupType
{
SUBGROUP,
SINGLE_CHOICE,
MULTI_CHOICE
}
So it can be different number and types of controls, It is based on what the FeedbackSet consist of.
I want to get the Id of each selected FeedbackCode, so I'm trying to bind selecteditem event on the different controls to bind to the same command.
Damn it's hard to explain :)