示例#1
0
 //create table menu programmerly and dynamically
 private void TablesMenuGenerator(List <String> dataStrings)
 {
     foreach (var element in dataStrings)
     {
         MenuItem menuItem = new MenuItem
         {
             Header = element
         };
         menuItem.Click += (sender, e) =>
         {
             DataGrid dataGrid = new DataGrid();
             if (element == PRODUTOS)
             {
                 dataGrid = Produto.GetDataGrid();
             }
             if (element == DESPESAS)
             {
                 dataGrid = Despesa.GetDataGrid();
             }
             if (element == IVA)
             {
                 dataGrid = Iva.GetDataGrid();
             }
             if (element == RECEITAS)
             {
                 dataGrid = Receita.GetDataGrid();
             }
             Grid.SetRow(dataGrid, 1);
             CleanDataGrid();
             mainGrid.Children.Add(dataGrid);
         };
         tablesMenu.Items.Add(menuItem);
     }
 }