一个适用于 WinUI 的轻量级 TableView/DataGrid。
WinUI.TableView is a lightweight and fast data grid control made for WinUI apps and now supports the Uno Platform. It is easy to use, and capable of handling large numbers 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.
Explore the interactive WinUI.TableView samples with code snippets in a Samples App on Microsoft Store or Uno Platorm WASM:
ShowExportOptions = true. Learn more →RowDetailsTemplate. Learn more →RowHeaderTemplate. Learn more →Browse the full documentation at w-ahmad.dev/WinUI.TableView
WinUI.TableView is compatible with the Uno Platform, enabling you to use the control across multiple platforms.
Try the Uno WASM Sample App here https://tableview.samples.w-ahmad.dev/
See the Uno Platform getting started guide for setup instructions.
For a complete walkthrough, see the Getting Started guide in the documentation.
If you don't already have a WinUI 3 project or Uno project, create one in Visual Studio.
Install WinUI.TableView NuGet package to your app with your preferred method. Here is the one using NuGet Package Manager:
Install-Package WinUI.TableViewWinUI.TableView to Your XAMLIn your MainWindow.xaml, add the WinUI.TableView control:
TableViewIn 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 Items { get; set; }
public MainViewModel()
{
Items = new ObservableCollection
{
new Item { Name = "Item 1", Price = 10.0, Quantity = 1 },
new Item { Name = "Item 2", Price = 15.0, Quantity = 2 },
new Item { Name = "Item 3", Price = 20.0, Quantity = 3 },
// Add more items here
};
}
}
public class Item
{
public string Name { get; set; }
public double Price { get; set; }
public int Quantity { get; set; }
}Build and run your application. You should see the TableView populated with the rows and cells from your ViewModel.
TableView relies heavily on runtime bindings and dynamic value resolution, which are not fully compatible with IL trimming and Native AOT by default.
To use TableView in Native AOT applications, bound types should be decorated with the WinRT.GeneratedBindableCustomProperty attribute to preserve the required binding metadata.
[WinRT.GeneratedBindableCustomProperty]
public partial class Person
{
public string Name { get; set; }
public int Age { get; set; }
}See the AOT compatibility docs for more details.
You can customize the appearance and behavior of the TableView by modifying its properties, templates, and styles. For example:
CornerButtonMode property to configure the corner button's behavior. You can select from:None: No corner button.SelectAll: Displays a "Select All" button.Options: Displays an options menu.
For full details on each column type, see the Column Types documentation.
Full documentation is available at w-ahmad.dev/WinUI.TableView, including:
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.
This project is licensed under the MIT License.
暂无开放 Issues,或尚未同步最近议题。