Liza Smerdova il y a 7 mois
Parent
commit
c0054cc918
2 fichiers modifiés avec 42 ajouts et 3 suppressions
  1. 8 2
      PDK_Concert/Pages/NumberPage.xaml
  2. 34 1
      PDK_Concert/Pages/NumberPage.xaml.cs

+ 8 - 2
PDK_Concert/Pages/NumberPage.xaml

@@ -10,11 +10,17 @@
 
     <Grid>
         <Grid.RowDefinitions>
-            <RowDefinition Height="60"/>
+            <RowDefinition Height="100"/>
             <RowDefinition Height="*"/>
             <RowDefinition Height="50"/>
         </Grid.RowDefinitions>
-        <TextBlock Text="Мои номера" Margin="10" Style="{StaticResource Title}" HorizontalAlignment="Center"/>
+        <StackPanel>
+            <TextBlock Text="Мои номера" Margin="10" Style="{StaticResource Title}" HorizontalAlignment="Center"/>
+            <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
+                <TextBlock Text="Поиск" Style="{StaticResource Menu}" Margin="0 0 30 0"/>
+                <TextBox TextChanged="poisk_TextChanged" Name="poisk" Width="500"/>
+            </StackPanel>
+        </StackPanel>
         <ListView Grid.Row="1" HorizontalContentAlignment="Stretch" Name="listNumbers">
             <ListView.ItemTemplate>
                 <DataTemplate>

+ 34 - 1
PDK_Concert/Pages/NumberPage.xaml.cs

@@ -21,12 +21,14 @@ namespace PDK_Concert.Pages
     public partial class NumberPage : Page
     {
         Logined logined;
+        List<Numbers> showNumbers;
         public NumberPage(Logined logined)
         {
             InitializeComponent();
             this.logined = logined;
             listNumbers.ItemsSource = Classes.DataBaseClass.connect.Numbers.Where(x => x.IDUser == logined.ID).ToList();
-            if(listNumbers==null)
+            showNumbers = Classes.DataBaseClass.connect.Numbers.Where(x => x.IDUser == logined.ID).ToList();
+            if (listNumbers==null)
             {
                 not.Visibility = Visibility.Visible;
                 listNumbers.Visibility = Visibility.Collapsed;
@@ -37,5 +39,36 @@ namespace PDK_Concert.Pages
         {
 
         }
+
+        private void poisk_TextChanged(object sender, TextChangedEventArgs e)
+        {
+            string text = poisk.Text;
+            UpdateList(text);
+        }
+
+        private void UpdateList(string text)
+        {
+            if(!string.IsNullOrEmpty(text))
+            {
+                showNumbers = showNumbers.Where(x=>x.Title.ToLower().Contains(text.ToLower())).ToList();
+                if(showNumbers.Count>0)
+                {
+                    listNumbers.ItemsSource = showNumbers;
+                    not.Visibility = Visibility.Collapsed;
+                    listNumbers.Visibility = Visibility.Visible;
+                }
+                else
+                {
+                    listNumbers.ItemsSource = Classes.DataBaseClass.connect.Numbers.Where(x => x.IDUser == logined.ID).ToList();
+                    not.Visibility = Visibility.Visible;
+                    listNumbers.Visibility = Visibility.Collapsed;
+                }
+            }
+            if(text=="")
+            {
+                not.Visibility = Visibility.Collapsed;
+                listNumbers.Visibility = Visibility.Visible;
+            }
+        }
     }
 }