Pārlūkot izejas kodu

fix: add function add TextBox in StackPanel for Labitinth play

klmnvan 4 mēneši atpakaļ
vecāks
revīzija
c1269d153f

+ 15 - 6
HelloItQuantum/ViewModels/LabyrinthViewModel.cs

@@ -2,29 +2,38 @@ using System;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
 using System.Windows.Input;
+using Avalonia.Controls;
+using DynamicData;
 using ReactiveUI;
 
 namespace HelloItQuantum.ViewModels
 {
-    public class LabyrinthViewModel : ReactiveObject
+    public class LabyrinthViewModel : MainWindowViewModel
     {
-        private List<NameComand> listCommandForRobots = new List<NameComand>();
+
+        /*private List<NameComand> listCommandForRobots = new List<NameComand>();
 
         public List<NameComand> ListCommandForRobots { get => listCommandForRobots; set => listCommandForRobots = value; }
 
-        public void addRight() {
+        public void AddRight() {
             ListCommandForRobots.Add(new NameComand { name = "go right" });
 
-        }
+        }*/
 
-        
+        StackPanel listCommandForRobots = new StackPanel();
+        public StackPanel ListCommandForRobots { get => listCommandForRobots; set => SetProperty(ref listCommandForRobots, value); }
 
+        public void AddRight()
+        {
+            TextBox tb = new TextBox();
+            tb.Text = "Ïðèâèâè";
+            ListCommandForRobots.Children.Add(tb);
 
+        }
     }
 
     public class NameComand {
         public string name { get; set; }
-
     }
 
 }

+ 5 - 13
HelloItQuantum/Views/LabyrinthView.axaml

@@ -39,18 +39,10 @@
 			<!--Область "кода"-->
 			<Panel Grid.Column="0" Grid.Row="0" >
 					<ScrollViewer>
-						<ListBox ItemsSource="{Binding LabyrinthVM.ListCommandForRobots}" Background="#F26527" CornerRadius="15"
-					Margin="20,25,20,30">
-							<ListBox.ItemTemplate>
-								<DataTemplate >
-									<StackPanel>
-										<Border CornerRadius="15">
-											<TextBlock Foreground="Black" Text="{Binding }"></TextBlock>
-										</Border>
-									</StackPanel>
-								</DataTemplate>
-							</ListBox.ItemTemplate>
-						</ListBox>
+						<UserControl
+							Content="{Binding LabyrinthVM.ListCommandForRobots}"
+							HorizontalAlignment="Center"
+							Margin="10"/>
 					</ScrollViewer>
 			</Panel>
 			<!--Область кнопок-->
@@ -69,7 +61,7 @@
 							<Button Width="40" CornerRadius="10000" Padding="1" Margin="0,0,5,0">
 								<Image Source="/Assets/ImgLabyrinth/img_right.png"/>
 							</Button>
-							<Button Command="{Binding LabyrinthVM.addRight}" Width="150" FontSize="24" Background="#F26527">go right</Button>
+							<Button Command="{Binding LabyrinthVM.AddRight}" Width="150" FontSize="24" Background="#F26527">go right</Button>
 						</StackPanel>
 						<StackPanel Margin="0,10,0,0" Orientation="Horizontal" VerticalAlignment="Top" >
 							<Button Width="40" CornerRadius="10000" Padding="1" Margin="0,0,5,0">