Bladeren bron

Каталог лучше чем было но тоже не оч

semen 5 maanden geleden
bovenliggende
commit
545edfa2be
2 gewijzigde bestanden met toevoegingen van 7 en 7 verwijderingen
  1. 6 4
      FoodLogProject/ViewModels/MainWindowViewModel.cs
  2. 1 3
      FoodLogProject/Views/Page7.axaml

+ 6 - 4
FoodLogProject/ViewModels/MainWindowViewModel.cs

@@ -13,14 +13,12 @@ namespace FoodLogProject.ViewModels
     {
 
 #pragma warning disable CA1822 // Mark members as static
-        static int id = 3;
         public static GaruaevContext myConnection = new GaruaevContext();
         public UserControl UC { get => uc; set => this.RaiseAndSetIfChanged(ref uc, value); }
         public Page2ViewModel Page2VM { get => page2VM; set => page2VM = value; }
         public Page6ViewModel Page6VM { get => page6VM; set => page6VM = value; }
         public List<Recipe> ListRecipes { get => listRecipes; set => listRecipes = value; }
         public List<RecipesIngredient> ListIngridient { get => listIngridient; set => listIngridient = value; }
-        public static int Id { get => id; set => id = value; }
 
         private UserControl uc = new Page1();
         public void LoadPage2() => UC = new Page2();
@@ -46,13 +44,17 @@ namespace FoodLogProject.ViewModels
         public void LoadPage5() => UC = new Page5();
         public void LoadPage6() => UC = new Page6();
         public void LoadPage7()
-        {
-            listIngridient = myConnection.RecipesIngredients.Include(x => x.Ingredient).Where(x => x.RecipeId == Id).ToList();
+        {            
             UC = new Page7();
         }
         private List<RecipesIngredient> listIngridient;
         private List<Recipe> listRecipes = myConnection.Recipes.ToList();
 
+        public void LookRecipe(int Id)
+        {
+            listIngridient = myConnection.RecipesIngredients.Include(x => x.Ingredient).Where(x => x.RecipeId == Id).ToList();
+            UC = new Page7();
+        }
 
 #pragma warning restore CA1822 // Mark members as static
     }

+ 1 - 3
FoodLogProject/Views/Page7.axaml

@@ -35,10 +35,8 @@
 							<DataTemplate>
 					<StackPanel >
 						<StackPanel >
-							<TextBlock Text="{Binding RecipeId}"/>
-							<TextBox Text="{Binding $parent[Window].((vm:MainWindowViewModel)DataContext).Id}"/>
 							<TextBlock Text="{Binding RecipeName}" FontSize="20"  FontWeight="Bold" Margin="0,0,0,20" HorizontalAlignment="Center" Name="NameOfRec"/>
-
+							<Button Foreground="White" Background="Green" HorizontalAlignment="Center" Margin="40" Content="Посмотреть ингридиенты" Command="{Binding $parent[Window].((vm:MainWindowViewModel)DataContext).LookRecipe}" CommandParameter="{Binding RecipeId}"/>
 							<TextBlock FontWeight="Bold" Margin="0,0,0,10">Ингредиенты</TextBlock>
 							<ListBox ItemsSource="{Binding $parent[Window].((vm:MainWindowViewModel)DataContext).ListIngridient}">
 								<ListBox.ItemTemplate>