Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MainWindow.xaml.cs
- private ObservableCollection<User> users = new ObservableCollection<User>();
- private ListCollectionView View
- {
- get
- {
- return (ListCollectionView)CollectionViewSource.GetDefaultView(users);
- }
- }
- private void filterBtn_Click(object sender, RoutedEventArgs e)
- {
- if(decimal.TryParse(paymentFrom.Text, out decimal cash) && decimal.TryParse(paymenTo.Text, out decimal cash1))
- {
- View.Filter = delegate (object item)
- {
- User user = (User)item;
- return (user.Payment >= cash && user.Payment <= cash1);
- };
- }
- }
- MainWindow.xaml
- <Window.Resources>
- ...............
- <DataTemplate x:Key="GroupTemplate">
- <TextBlock Text="{Binding Path=Name}" FontWeight="Bold" Foreground="White" Background="DodgerBlue" Margin="0,5,0,0" Padding="3"/>
- </DataTemplate>
- </Window.Resources>
- ........
- <ListBox Grid.Row="1" Name="usersList" Margin="10" Padding="5 5 0 5" SelectionChanged="sex_SelectionChanged" ItemTemplate="{StaticResource UserDataTemplate}" HorizontalContentAlignment="Stretch">
- <ListBox.Template>
- <ControlTemplate>
- <StackPanel>
- <ItemsPresenter/>
- <Button Margin="5" Padding="10 5" Click="ListBoxItem_Click" Content="dodaj nową osobę..."/>
- </StackPanel>
- </ControlTemplate>
- </ListBox.Template>
- <ListBox.GroupStyle>
- <GroupStyle HeaderTemplate="{StaticResource GroupTemplate}"/>
- </ListBox.GroupStyle>
- </ListBox>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement