WinUI.TableView
1.2.2
dotnet add package WinUI.TableView --version 1.2.2
NuGet\Install-Package WinUI.TableView -Version 1.2.2
<PackageReference Include="WinUI.TableView" Version="1.2.2" />
paket add WinUI.TableView --version 1.2.2
#r "nuget: WinUI.TableView, 1.2.2"
// Install WinUI.TableView as a Cake Addin #addin nuget:?package=WinUI.TableView&version=1.2.2 // Install WinUI.TableView as a Cake Tool #tool nuget:?package=WinUI.TableView&version=1.2.2
WinUI.TableView
WinUI.TableView
is a lightweight and fast data grid control made for WinUI apps. It is easy to use, and capable of handling large number of items with a focus on performance. It's derived from ListView
so you will experience fluent look and feel in your project. It comes with all the essential features you need, plus extras like an Excel like column filter, options buttons (for columns and the TableView) and easy data export.
Contributors
<a href="https://github.com/w-ahmad/WinUI.TableView/graphs/contributors"> <img src="https://contrib.rocks/image?repo=w-ahmad/WinUI.TableView" /> </a>
Features
- Auto-generating Columns: Automatically generate columns based on the data source.
- Individual cell selection: You can select any cell for the ease of access and better editing experience.
- Copy row or cell content: TableView allows you to copy rows or cells content, with the option to include or exclude column headers.
- Editing: Modify cell content directly within the TableView by double tapping on a cell.
- Sorting: Offers built in column sorting.
- Excel-like Column Filter: TableView allows you to filter data within columns with an excel like flyout to enhance data exploration and analysis.
- Export functionality: Built-in export functionality to export data to CSV format. This feature can be enabled by setting the
ShowExportOptions = true
.
Getting Started
1: Install NuGet package to your project
You can install the WinUI.TableView
NuGet package using the NuGet Package Manager or by running the following command in the Package Manager Console:
Install-Package WinUI.TableView
2. Create a New WinUI 3 Project
If you don't already have a WinUI 3 project, create one in Visual Studio.
3. Add WinUI.TableView
to Your XAML
In your MainWindow.xaml
, add the WinUI.TableView
control:
<Window
x:Class="App1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:App1"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
xmlns:tableView="using:WinUI.TableView">
<Grid>
<tableView:TableView x:Name="MyTableView"
ItemsSource="{x:Bind ViewModel.Items}"
AutoGenerateColumns="True" />
</Grid>
</Window>
4. Bind Data to TableView
In your MainPage.xaml.cs
, set up the data context and bind data to the TableView
:
public sealed partial class MainWindow : Window
{
public MainViewModel ViewModel { get; } = new MainViewModel();
public MainWindow()
{
this.InitializeComponent();
}
}
Create a simple MainViewModel
with a collection of items to display:
public class MainViewModel
{
public ObservableCollection<Item> Items { get; set; }
public MainViewModel()
{
Items = new ObservableCollection<Item>
{
new Item { Name = "Item 1", Price = 10.0, Quantity = 1 },
new Item { Name = "Item 2", Price = 15.0, Quantity = 2 },
// Add more items here
};
}
}
public class Item : INotifyPropertyChanged
{
private string _name;
private double _price;
private int _quantity;
public string Name
{
get => _name;
set
{
_name = value;
OnPropertyChanged(nameof(Name));
}
}
public double Price
{
get => _price;
set
{
_price = value;
OnPropertyChanged(nameof(Price));
}
}
public int Quantity
{
get => _quantity;
set
{
_quantity = value;
OnPropertyChanged(nameof(Quantity));
}
}
private void OnPropertyChanged(string propertyName)
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public event PropertyChangedEventHandler PropertyChanged;
}
5. Run Your Application
Build and run your application. You should see the TableView
populated with the rows and cells from your ViewModel
.
Customization
You can customize the appearance and behavior of the TableView
by modifying its properties, templates, and styles. For example:
- Column Customization: Define custom columns based on data types.
- Is ReadOnly: You can make any column or the TableView itself read only.
- Sorting and Filtering: Enable sorting and filtering on specific columns or for the all columns.
- TableView Options: Turn on or off options flyout for the TableView based on your requirements.
<tableView:TableView x:Name="MyTableView"
ItemsSource="{x:Bind ViewModel.Items}"
AutoGenerateColumns="False">
<tableView:TableView.Columns>
<tableView:TableViewTextColumn Header="Name" Binding="{Binding Name}" />
<tableView:TableViewNumberColumn Header="Price" Binding="{Binding Price}" />
<tableView:TableViewTemplateColumn Header="Quantity">
<tableView:TableViewTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Quantity}" />
</DataTemplate>
</tableView:TableViewTemplateColumn.CellTemplate>
<tableView:TableViewTemplateColumn.EditingTemplate>
<DataTemplate>
<NumberBox Value="{Binding Quantity, Mode=TwoWay}" />
</DataTemplate>
</tableView:TableViewTemplateColumn.EditingTemplate>
</tableView:TableViewTemplateColumn>
</tableView:TableView.Columns>
</tableView:TableView>
Available Column Types
- TableViewTextColumn
- TableViewCheckBoxColumn
- TableViewComboBoxColumn
- TableViewNumberColumn
- TableViewToggleSwitchColumn
- TableViewTemplateColumn
Contributing
Contributions are welcome from the community! If you find any issues or have suggestions for improvements, please submit them through the GitHub issue tracker or consider making a pull request.
License
This project is licensed under the MIT License.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0-windows10.0.19041 is compatible. net7.0-windows was computed. net8.0-windows was computed. |
-
net6.0-windows10.0.19041
- CommunityToolkit.WinUI.Behaviors (>= 8.0.240109)
- Microsoft.WindowsAppSDK (>= 1.5.240227000)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.2.2 | 297 | 11/26/2024 |
1.2.1 | 446 | 10/12/2024 |
1.2.0 | 412 | 8/14/2024 |
1.2.0-preview2 | 111 | 7/9/2024 |
1.2.0-preview1 | 113 | 6/18/2024 |
1.1.1 | 368 | 5/19/2024 |
1.1.0 | 188 | 5/5/2024 |
1.0.0 | 181 | 4/20/2024 |
1.0.0-preview4 | 119 | 3/26/2024 |
1.0.0-preview3 | 92 | 3/5/2024 |
1.0.0-preview2 | 96 | 2/18/2024 |
1.0.0-preview1 | 103 | 2/4/2024 |