// Constructor public MainWindow() { // Set the data context of the window to the MainWindowViewModel class DataContext = View.Model.MainWindow; // Populate initial data in the user interface's food list List <string> l = USDA.GetFoodList("", true); MessageBox.Show(l.Count.ToString()); View.Model.MainWindow.FoodList = USDA.GetFoodList("", true); // Populate the tree view List <string> list = USDA.GetFoodGroups(); foreach (var group in list) { CategorizedFoodListItem entry = new CategorizedFoodListItem(group, USDA.GetFoodListByGroup(group)); View.Model.MainWindow.CategorizedFoodList.Add(entry); } // Load user data UserData data = UserData.Load(); if (data != null) { View.Model.MainWindow.UserData = data; } // Load the user interface InitializeComponent(); // Set name scopes for context menus so they can bind to elements in the XAML tree NameScope.SetNameScope(DietPlanDataGridContextMenu, NameScope.GetNameScope(this)); }
public void Execute(object parameter) { // Delegate to the USDA.GetFoodList method, passing both the search string as the first argument and the search mode based on radio selection View.Model.MainWindow.FoodList = USDA.GetFoodList(parameter.ToString(), View.Model.MainWindow.RadioButtonStartsWith); }