Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As requested, here are my ViewModels.</p> <p>ViewModelBase is the standard one created by studio. MainVieModel has got just enough to in it to create the test menus I was using to experiment with. </p> <p>Basically I am working towards creating a Parent/Child menu classes I can use with a series of apps we sell to a broad collection of clients. I hope to make it where each customer can have a customizable collection of menus based upon their needs and which moudles they've purchased licenses for.</p> <pre><code>public abstract class ViewModelBase : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; protected void OnPropertyChanged(string propertyName) { PropertyChangedEventHandler handler = PropertyChanged; if (handler != null) { handler(this, new PropertyChangedEventArgs(propertyName)); } } } </code></pre> <p>public class MainViewModel : ViewModelBase</p> <p>{</p> <pre><code> public MainViewModel() { MakeMenus(); } private void MakeMenus() { // Makes some dummy menus to test with. Menus = new ObservableCollection&lt;MyMenuItem&gt;(); ParentMenu parent; ChildMenu child; parent = new ParentMenu("First Level"); Menus.Add(parent); child = new ChildMenu(parent, "second level"); parent.ChildMenuItems.Add(child); ChildMenu child2 = new ChildMenu(child, "third level"); child2.MenuCommand = new DelegateCommand(CommandTest, CommandCanExecute_First); child.ChildMenuItems.Add(child2); child = new ChildMenu(parent, "second level 2"); parent.ChildMenuItems.Add(child); child2 = new ChildMenu(child, "third level 2"); child2.MenuCommand = new DelegateCommand(CommandTest, CommandCanExecute_Second); child.ChildMenuItems.Add(child2); parent = new ParentMenu("Another First"); parent.ChildMenuItems.Add(new ChildMenu(parent, "Another Second")); Menus.Add(parent); OnPropertyChanged("Menus"); } private bool ExecuteToggle { get; set; } private void CommandTest() { ExecuteToggle = !ExecuteToggle; } public ObservableCollection&lt;MyMenuItem&gt; Menus { get; private set;} public bool CommandCanExecute_First() { return ExecuteToggle; } public bool CommandCanExecute_Second() { return !ExecuteToggle; } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload