SimpleDataGrid 0.8.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
Requires NuGet 4.1.0 or higher.
dotnet add package SimpleDataGrid --version 0.8.1
NuGet\Install-Package SimpleDataGrid -Version 0.8.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="SimpleDataGrid" Version="0.8.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="SimpleDataGrid" Version="0.8.1" />
<PackageReference Include="SimpleDataGrid" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add SimpleDataGrid --version 0.8.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: SimpleDataGrid, 0.8.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package SimpleDataGrid@0.8.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=SimpleDataGrid&version=0.8.1
#tool nuget:?package=SimpleDataGrid&version=0.8.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
<img src="https://github.com/DerekGooding/SimpleInjection/blob/main/Icon.png" width=50 height=50/> SimpleDataGrid
A simple DataGrid for WPF that supports pagination, filtering, and searching.
Features
- Pagination: Easily page through large datasets.
- Filtering: Filter data based on custom criteria.
- Searching: Search for data using strings or wildcards.
Installation
You can install the SimpleDataGrid NuGet package using either the .NET CLI or the NuGet Package Manager.
.NET CLI
dotnet add package SimpleDataGrid
NuGet Package Manager
Install-Package SimpleDataGrid
Usage
- Install the
SimpleDataGridNuGet package. - Add the
PagedDataGridcontrol to your XAML. - Create a
PagedCollectionand bind it to thePagedSourceproperty of thePagedDataGrid.
<Window x:Class="SimpleDataGrid.Example.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:SimpleDataGrid.Example"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Window.DataContext>
<local:MainViewModel />
</Window.DataContext>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Horizontal" Margin="5">
<TextBox x:Name="SearchTextBox" Width="200" Margin="5" />
<Button Content="Search" Click="SearchButton_Click" Margin="5" />
<CheckBox x:Name="WildcardCheckBox" Content="Use Wildcards" VerticalAlignment="Center" Margin="5" />
<TextBox x:Name="MinAgeTextBox" Width="50" Margin="5" />
<Button Content="Filter by Min Age" Click="FilterButton_Click" Margin="5" />
<Button Content="Clear Filter" Click="ClearFilterButton_Click" Margin="5" />
</StackPanel>
<local:PersonPagedDataGrid x:Name="PagedDataGrid" Grid.Row="1" PagedSource="{Binding People}" AutoGenerateColumns="True" />
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Center">
<Button Content="Previous" Click="PreviousButton_Click" Margin="5" />
<TextBlock Text="{Binding People.CurrentPage}" VerticalAlignment="Center" Margin="5" />
<TextBlock Text="/" VerticalAlignment="Center" />
<TextBlock Text="{Binding People.TotalPages}" VerticalAlignment="Center" Margin="5" />
<Button Content="Next" Click="NextButton_Click" Margin="5" />
</StackPanel>
</Grid>
</Window>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void PreviousButton_Click(object sender, RoutedEventArgs e)
{
var viewModel = (MainViewModel)DataContext;
viewModel.People.PreviousPage();
}
private void NextButton_Click(object sender, RoutedEventArgs e)
{
var viewModel = (MainViewModel)DataContext;
viewModel.People.NextPage();
}
private void SearchButton_Click(object sender, RoutedEventArgs e)
{
var viewModel = (MainViewModel)DataContext;
viewModel.People.SetSearch(p => p.Name, SearchTextBox.Text, WildcardCheckBox.IsChecked == true);
}
private void FilterButton_Click(object sender, RoutedEventArgs e)
{
var viewModel = (MainViewModel)DataContext;
if (int.TryParse(MinAgeTextBox.Text, out var minAge))
{
viewModel.ApplyFilter(minAge);
}
}
private void ClearFilterButton_Click(object sender, RoutedEventArgs e)
{
var viewModel = (MainViewModel)DataContext;
viewModel.ClearFilter();
}
}
public class MainViewModel
{
public PagedCollection<Person> People { get; }
public MainViewModel()
{
People = new PagedCollection<Person>(10);
People.SetSource(GetPeople());
}
private static List<Person> GetPeople()
{
var people = new List<Person>();
for (var i = 1; i <= 100; i++)
{
people.Add(new Person { Id = i, Name = $"Person {i}", Age = 20 + (i % 50) });
}
return people;
}
public void ApplyFilter(int minAge)
{
People.ClearFilters();
People.AddFilter(p => p.Age >= minAge);
}
public void ClearFilter()
{
People.ClearFilters();
}
}
License
This project is licensed under the MIT License. See the LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0-windows7.0 is compatible. net9.0-windows was computed. net9.0-windows7.0 is compatible. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0-windows7.0
- No dependencies.
-
net9.0-windows7.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.