syncfusion-wpf-card-view
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseImplementing CardView (WPF)
实现CardView(WPF)
A panel control that organizes items as visual cards with built-in grouping, sorting, filtering, and inline editing.
这是一款面板控件,可将数据项组织为可视化卡片,内置分组、排序、筛选和内联编辑功能。
When to Use This Skill
适用场景
Use this skill when the user needs to:
- Display a collection of data items as cards in a WPF application
- Enable grouping, sorting, or filtering of card items
- Add inline editing to card items (F2 / double-click)
- Customize card header, body, or edit UI via templates
- Bind card items to an (MVVM)
ObservableCollection - Apply themes or localize CardView strings
Note: Grouping, sorting, filtering, and editing requiredata binding. These features do not work with declarativeItemsSourcechildren.CardViewItem
当用户需要以下功能时,可使用本技能:
- 在WPF应用中将数据项集合以卡片形式展示
- 启用卡片项的分组、排序或筛选功能
- 为卡片项添加内联编辑(按F2键/双击)
- 通过模板自定义卡片的页眉、正文或编辑界面
- 将卡片项绑定到(MVVM模式)
ObservableCollection - 应用主题或本地化CardView字符串
注意: 分组、排序、筛选和编辑功能需要通过绑定数据。这些功能不支持声明式的ItemsSource子元素。CardViewItem
Component Overview
组件概述
| Class | Namespace | Purpose |
|---|---|---|
| | Container panel for card items |
| | Individual card (declarative use) |
Required Assemblies: +
Syncfusion.Shared.WPFSyncfusion.Tools.WPFXAML Namespace:
xml
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"| 类 | 命名空间 | 用途 |
|---|---|---|
| | 卡片项的容器面板 |
| | 单个卡片(声明式使用) |
所需程序集: +
Syncfusion.Shared.WPFSyncfusion.Tools.WPFXAML命名空间:
xml
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"Documentation and Navigation Guide
文档与导航指南
Getting Started
快速入门
📄 Read: references/getting-started.md
- Assembly and namespace setup
- Add CardView via designer, XAML, or C#
- Declarative approach
CardViewItem - data binding approach
ItemsSource - ,
SelectedItem,IsSelectedSelectedItemChanged - (Horizontal / Vertical)
Orientation - SfSkinManager theme setup
📄 阅读: references/getting-started.md
- 程序集和命名空间设置
- 通过设计器、XAML或C#添加CardView
- 声明式实现方式
CardViewItem - 数据绑定实现方式
ItemsSource - 、
SelectedItem、IsSelected事件SelectedItemChanged - (水平/垂直)布局
Orientation - SfSkinManager主题设置
Data Binding & Templates
数据绑定与模板
📄 Read: references/data-binding-and-templates.md
- Full Model + ViewModel + pattern
ObservableCollection - — card header display
HeaderTemplate - — card body in view mode
ItemTemplate - — card body in edit mode
EditItemTemplate - and
ItemContainerStyleItemContainerStyleSelector - for RTL layouts
FlowDirection - SfSkinManager visual styles reference
📄 阅读: references/data-binding-and-templates.md
- 完整的Model + ViewModel + 模式
ObservableCollection - —— 卡片页眉展示模板
HeaderTemplate - —— 卡片正文的查看模式模板
ItemTemplate - —— 卡片正文的编辑模式模板
EditItemTemplate - 和
ItemContainerStyle样式设置ItemContainerStyleSelector - 用于RTL布局的属性
FlowDirection - SfSkinManager视觉样式参考
Grouping
分组功能
📄 Read: references/grouping.md
- enable/disable
CanGroup - Drag-drop fields to group header
- programmatic grouping
GroupCards(string) - Nested / multi-level grouping
- to hide the grouping region
ShowHeader
📄 阅读: references/grouping.md
- 属性启用/禁用分组
CanGroup - 拖拽字段到分组页眉进行分组
- 编程式分组方法
GroupCards(string) - 嵌套/多级分组
- 属性隐藏分组区域
ShowHeader
Sorting & Filtering
排序与筛选
📄 Read: references/sorting-and-filtering.md
- enable/disable; click field name to cycle sort order
CanSort - Sorting grouped items via drop region
- enable/disable; popup-based field value filter
CanFilter - Clear Filter button behavior
- to hide sorting/filtering header
ShowHeader
📄 阅读: references/sorting-and-filtering.md
- 属性启用/禁用排序;点击字段名切换排序顺序
CanSort - 通过拖拽区域对分组项进行排序
- 属性启用/禁用筛选;基于弹出框的字段值筛选
CanFilter - 清除筛选按钮的行为
- 属性隐藏排序/筛选页眉
ShowHeader
Editing
编辑功能
📄 Read: references/editing.md
- enable/disable (default
CanEdit)false - F2 / double-click to enter edit mode; Esc/Enter to exit
- requirement and pattern
EditItemTemplate - /
BeginEdit()programmatic controlEndEdit() - Custom edit UI styling
📄 阅读: references/editing.md
- 属性启用/禁用编辑(默认值
CanEdit)false - 按F2键/双击进入编辑模式;按Esc/Enter键退出
- 模板的要求与实现模式
EditItemTemplate - /
BeginEdit()编程式编辑控制EndEdit() - 自定义编辑界面样式
Localization
本地化
📄 Read: references/localization.md
- setup
CurrentUICulture - Resource file naming convention
- Name/Value pair configuration
- French culture example
📄 阅读: references/localization.md
- 设置
CurrentUICulture - 资源文件命名规范
- 键值对配置
- 法语区域设置示例
Quick Start Example
快速入门示例
Minimal CardView with data binding and grouping/sorting:
xml
<!-- MainWindow.xaml -->
<Window xmlns:syncfusion="http://schemas.syncfusion.com/wpf">
<Window.DataContext>
<local:ViewModel/>
</Window.DataContext>
<syncfusion:CardView ItemsSource="{Binding CardViewItems}"
CanGroup="True"
CanSort="True"
Name="cardView">
<syncfusion:CardView.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding FirstName}"/>
</DataTemplate>
</syncfusion:CardView.HeaderTemplate>
<syncfusion:CardView.ItemTemplate>
<DataTemplate>
<ListBox ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListBoxItem>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Name: " FontWeight="Bold"/>
<TextBlock Text="{Binding FirstName}"/>
</StackPanel>
</ListBoxItem>
<ListBoxItem>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Age: " FontWeight="Bold"/>
<TextBlock Text="{Binding Age}"/>
</StackPanel>
</ListBoxItem>
</ListBox>
</DataTemplate>
</syncfusion:CardView.ItemTemplate>
</syncfusion:CardView>
</Window>csharp
// ViewModel.cs
public class ViewModel : NotificationObject
{
private ObservableCollection<Person> _items;
public ObservableCollection<Person> CardViewItems
{
get => _items;
set { _items = value; RaisePropertyChanged(nameof(CardViewItems)); }
}
public ViewModel()
{
CardViewItems = new ObservableCollection<Person>
{
new Person { FirstName = "Alice", LastName = "Smith", Age = 30 },
new Person { FirstName = "Bob", LastName = "Jones", Age = 25 },
new Person { FirstName = "Carol", LastName = "Smith", Age = 28 },
};
}
}具备数据绑定和分组/排序功能的极简CardView:
xml
<!-- MainWindow.xaml -->
<Window xmlns:syncfusion="http://schemas.syncfusion.com/wpf">
<Window.DataContext>
<local:ViewModel/>
</Window.DataContext>
<syncfusion:CardView ItemsSource="{Binding CardViewItems}"
CanGroup="True"
CanSort="True"
Name="cardView">
<syncfusion:CardView.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding FirstName}"/>
</DataTemplate>
</syncfusion:CardView.HeaderTemplate>
<syncfusion:CardView.ItemTemplate>
<DataTemplate>
<ListBox ScrollViewer.HorizontalScrollBarVisibility="Disabled">
<ListBoxItem>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Name: " FontWeight="Bold"/>
<TextBlock Text="{Binding FirstName}"/>
</StackPanel>
</ListBoxItem>
<ListBoxItem>
<StackPanel Orientation="Horizontal">
<TextBlock Text="Age: " FontWeight="Bold"/>
<TextBlock Text="{Binding Age}"/>
</StackPanel>
</ListBoxItem>
</ListBox>
</DataTemplate>
</syncfusion:CardView.ItemTemplate>
</syncfusion:CardView>
</Window>csharp
// ViewModel.cs
public class ViewModel : NotificationObject
{
private ObservableCollection<Person> _items;
public ObservableCollection<Person> CardViewItems
{
get => _items;
set { _items = value; RaisePropertyChanged(nameof(CardViewItems)); }
}
public ViewModel()
{
CardViewItems = new ObservableCollection<Person>
{
new Person { FirstName = "Alice", LastName = "Smith", Age = 30 },
new Person { FirstName = "Bob", LastName = "Jones", Age = 25 },
new Person { FirstName = "Carol", LastName = "Smith", Age = 28 },
};
}
}Common Patterns
常见模式
| Scenario | Properties / Methods |
|---|---|
| Enable all interactive modes | |
| Programmatic group by field | |
| Programmatic edit control | |
| Hide group/sort/filter header | |
| RTL layout | |
| React to selection | Handle |
| Apply theme | |
| 场景 | 属性/方法 |
|---|---|
| 启用所有交互模式 | |
| 编程式按字段分组 | |
| 编程式控制编辑 | |
| 隐藏分组/排序/筛选页眉 | |
| RTL布局 | |
| 响应选择事件 | 处理 |
| 应用主题 | |
Key Properties
关键属性
| Property | Type | Default | Description |
|---|---|---|---|
| | | Data collection to bind |
| | | Currently selected card |
| | | Card layout direction |
| | | Enable drag-drop grouping |
| | | Enable field click sorting |
| | | Enable inline editing |
| | | Show/hide group/sort/filter header |
| | — | Card header display template |
| | — | Card body in view mode |
| | — | Card body in edit mode |
| | — | Style applied to each card container |
| 属性 | 类型 | 默认值 | 描述 |
|---|---|---|---|
| | | 要绑定的数据集合 |
| | | 当前选中的卡片 |
| | | 卡片布局方向 |
| | | 启用拖拽分组功能 |
| | | 启用点击字段排序功能 |
| | | 启用内联编辑功能 |
| | | 显示/隐藏分组/排序/筛选页眉 |
| | — | 卡片页眉的展示模板 |
| | — | 卡片正文的查看模式模板 |
| | — | 卡片正文的编辑模式模板 |
| | — | 应用于每个卡片容器的样式 |