I am currently writing a GUI for a C# application that adheres to the following software requirements (and am struggling with the conceptual design):Have a GUI with some choices of different operations to run.Each possible selection choice on the GUI should have a few sub-selections that the user can pick from.Each of the selections should correspond with a certain object to be utilized.Each of the sub-selections should correspond with a certain method to run (belonging to the selected object).In one sentence, I am looking to associate the choices/options with different parts of executable code.I really want to figure out a way to separate these choices/selections from the application, but with my current level experience, the only thing that I know how to do is make a big switch statement and hard-code the selections/sub-selection operations based on the hard-coded strings. There has got to be another way of associating the selections with the operations but I am failing to understand.Let's say that I did decide to use XML and coded all of the possible selections, all that would allow me to do is populate them on the GUI. I would still have to hard-code the values in the application to make the decisions about what to do when they are selected right? I just don't see any other way.In case anyone is curious, I am using WPF to build this application.
Associate selection from GUI with executable code
c#;object oriented design;gui;wpf
I'd probably have an object model design that looked something like this :public interface ISelectionModel{    string DisplayName { get; }    List<string> SubSelections { get; }    void RunSubSelection(string sub);}public SelectionBaseModel : ISelectionModel{    private string _displayName;    private List<string> _subSelections;    public string DisplayName { get { return _displayName; }}    public List<string> SubSelections { get { return _subSelections; }}}public SelectionAModel : ISelectionModel{    public SelectionAModel()    {        _displayName = Selection A;        _subSelections = new List<string>() { Sub 1, Sub 2, Sub 3 });    }    public void RunSubSelection(string sel)    {        switch(sel)        {            case Sub 1:                Method1();                break;            case Sub 2:                Method2();                break;            case Sub 3:                Method3();                break;        }    }    private void Method1() { .. }    private void Method2() { .. }    private void Method3() { .. }}There is some hardcoding, but that's unavoidable I think since you need to write your code methods. It would be split out though, so only methods relevant to SelectionA should be in the SelectionA model, or shared methods for all Selections could go in the Base model. For display purposes, you'd have a list or collection of ISelectionModel objects bound to whatever control you choose to display the collection, and each item would display using another control with an ItemsSource for displaying the sub menu items. When clicking a sub item to run it, you would simply call something like SelectedSelection.Run(SelectedSelection.SelectedSub) from your ICommand.Each child object could be self-contained, and could be initialized from an XML file if you wanted. You could make the list of sub strings dynamic too, for example :Selection A1 of type SelectionAModel with { Sub 1, Sub 2 }Selection A2 of type SelectionAModel with { Sub 2, Sub 3 }Selection A3 of type SelectionAModel with { Sub 1, Sub 2, Sub 3 }Selection B of type SelectionBModel with { Sub 4, Sub 5 }