Advertisement
Guest User

Untitled

a guest
Apr 25th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.77 KB | None | 0 0
  1. MainWindow.xaml.cs
  2.  
  3. private ObservableCollection<User> users = new ObservableCollection<User>();
  4.  
  5.         private ListCollectionView View
  6.         {
  7.             get
  8.             {
  9.                 return (ListCollectionView)CollectionViewSource.GetDefaultView(users);
  10.             }
  11.         }
  12.  
  13. private void filterBtn_Click(object sender, RoutedEventArgs e)
  14.         {
  15.             if(decimal.TryParse(paymentFrom.Text, out decimal cash) && decimal.TryParse(paymenTo.Text, out decimal cash1))
  16.             {
  17.                 View.Filter = delegate (object item)
  18.                 {
  19.                     User user = (User)item;
  20.                     return (user.Payment >= cash && user.Payment <= cash1);
  21.                 };
  22.             }
  23.         }
  24.  
  25.  
  26. MainWindow.xaml
  27. <Window.Resources>
  28. ...............
  29.         <DataTemplate x:Key="GroupTemplate">
  30.             <TextBlock Text="{Binding Path=Name}" FontWeight="Bold" Foreground="White" Background="DodgerBlue" Margin="0,5,0,0" Padding="3"/>
  31.         </DataTemplate>
  32.  
  33.     </Window.Resources>
  34.  
  35. ........
  36.  
  37. <ListBox Grid.Row="1" Name="usersList" Margin="10" Padding="5 5 0 5" SelectionChanged="sex_SelectionChanged" ItemTemplate="{StaticResource UserDataTemplate}" HorizontalContentAlignment="Stretch">
  38.             <ListBox.Template>
  39.                 <ControlTemplate>
  40.                     <StackPanel>
  41.                         <ItemsPresenter/>
  42.                         <Button Margin="5" Padding="10 5" Click="ListBoxItem_Click" Content="dodaj nową osobę..."/>
  43.                     </StackPanel>
  44.                 </ControlTemplate>
  45.             </ListBox.Template>
  46.             <ListBox.GroupStyle>
  47.                 <GroupStyle HeaderTemplate="{StaticResource GroupTemplate}"/>
  48.             </ListBox.GroupStyle>
  49.            
  50.         </ListBox>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement