Imagara před 2 roky
rodič
revize
c3462e505d

+ 8 - 5
MyTests/ErrorWindow.xaml

@@ -12,21 +12,24 @@
         WindowStartupLocation="CenterScreen" 
         WindowStyle="None" 
         ResizeMode="NoResize">
-    <Grid Background="#FF2D2D2D">
-        <TextBlock Name="ErrorLabel" 
+    <Border Background="#FF2D2D2D"
+            MouseDown="Border_MouseDown">
+        <StackPanel>
+            <TextBlock Name="ErrorLabel" 
                Text="Ошибка." 
                TextWrapping="Wrap"
                HorizontalAlignment="Center" 
                Margin="19,10,19,0" 
                VerticalAlignment="Top" 
                Width="262">
-        </TextBlock>
-        <Button Content="Закрыть" 
+            </TextBlock>
+            <Button Content="Закрыть" 
                 VerticalAlignment="Bottom" 
                 HorizontalAlignment="Center" 
                 Height="30" 
                 Width="130" 
                 Margin="0,0,0,15" 
                 Click="BackClick"/>
-    </Grid>
+        </StackPanel>
+    </Border>
 </Window>

+ 7 - 0
MyTests/ErrorWindow.xaml.cs

@@ -1,4 +1,5 @@
 using System.Windows;
+using System.Windows.Input;
 
 namespace MyTests
 {
@@ -13,6 +14,12 @@ namespace MyTests
         {
             this.Close();
         }
+
+        private void Border_MouseDown(object sender, MouseButtonEventArgs e)
+        {
+            if (e.LeftButton == MouseButtonState.Pressed)
+                DragMove();
+        }
     }
 }
 

+ 3 - 2
MyTests/Pages/TestPage.xaml

@@ -44,10 +44,11 @@
             <ScrollViewer VerticalScrollBarVisibility="Visible"/>
             <ListBox.ItemTemplate>
                 <DataTemplate>
-                    <Border Width="640"
+                    <Border Width="{Binding Path=ActualWidth, ElementName=TestsListBox}"
                             Height="50"
                             CornerRadius="10"
-                            Background="{StaticResource color2}">
+                            Background="{StaticResource color2}"
+                            MouseDown="TestsListBox_Selected">
                         <StackPanel>
                             <Label Content="{Binding Content}"/>
                             <TextBox Name="Testing"

+ 19 - 1
MyTests/Pages/TestPage.xaml.cs

@@ -8,10 +8,12 @@ using System.Windows.Controls;
 using System.Windows.Data;
 using System.Windows.Documents;
 using System.Windows.Input;
+using System.Windows.Markup;
 using System.Windows.Media;
 using System.Windows.Media.Imaging;
 using System.Windows.Navigation;
 using System.Windows.Shapes;
+using System.Globalization;
 
 namespace MyTests.Pages
 {
@@ -30,7 +32,23 @@ namespace MyTests.Pages
         void LoadingQuestions()
         {
             TestsListBox.Items.Clear();
-            TestsListBox.ItemsSource = cnt.db.Questions.Where(item=>item.IdTest == testId).ToList(); ;
+            TestsListBox.ItemsSource = cnt.db.Questions.Where(item=>item.IdTest == testId).ToList();
+        }
+
+        private void TestsListBox_Selected(object sender, MouseButtonEventArgs e)
+        {
+            try
+            {
+                if (((Questions)TestsListBox.SelectedItem) != null)
+                {
+                    MessageBox.Show(((Questions)TestsListBox.SelectedItem).IdQuestion.ToString());
+                    MessageBox.Show($"{(ListBox)TestsListBox.FindName("Testing")}");
+                }
+            }
+            catch
+            {
+                new ErrorWindow("Ошибка открытия теста.").ShowDialog();
+            }
         }
     }
 }

+ 1 - 1
MyTests/Pages/TestsCatalog.xaml

@@ -55,7 +55,7 @@
             <ScrollViewer VerticalScrollBarVisibility="Visible"/>
             <ListBox.ItemTemplate>
                 <DataTemplate>
-                    <Border Width="785"
+                    <Border Width="{Binding Path=ActualWidth, ElementName=TestsListBox}"
                             Height="45"
                             CornerRadius="10"
                             Background="{StaticResource color2}"