syncfusion-wpf-avatar-view
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseImplementing SfAvatarView (WPF)
实现SfAvatarView(WPF)
When to Use This Skill
何时使用本技能
Use this skill when the user needs to:
- Display a user profile picture, initials, or avatar character
- Show text initials (single or double character) with a colored background
- Use pre-built avatar characters (Avatar1–Avatar25)
- Build a group avatar view from a data collection
- Customize avatar shape (Circle, Square, Custom) and size
- Apply borders, backgrounds, gradients, or font styling to an avatar
- Attach a badge (status indicator) to an avatar
Component:
Assembly:
XAML Namespace:
SfAvatarViewSyncfusion.Shared.WPFxmlns:syncfusion="http://schemas.syncfusion.com/wpf"当用户需要以下功能时可使用本技能:
- 显示用户资料图片、姓名首字母或头像角色
- 显示带彩色背景的文本首字母(单个或两个字符)
- 使用预构建的头像角色(Avatar1–Avatar25)
- 从数据集合构建群组头像视图
- 自定义头像形状(圆形、方形、自定义)和尺寸
- 为头像应用边框、背景、渐变或字体样式
- 为头像附加徽章(状态指示器)
组件:
程序集:
XAML命名空间:
SfAvatarViewSyncfusion.Shared.WPFxmlns:syncfusion="http://schemas.syncfusion.com/wpf"Component Overview
组件概述
SfAvatarView| ContentType | What it Shows |
|---|---|
| Built-in Avatar1 character, no setup needed |
| Text initials extracted from |
| User-supplied image via |
| One of 25 pre-built character images |
| Multiple avatars from a bound collection |
Shape is controlled by (Circle / Square / Custom). Size by (ExtraSmall → ExtraLarge).
AvatarShapeAvatarSizeSfAvatarView| ContentType | 显示内容 |
|---|---|
| 内置Avatar1角色,无需额外设置 |
| 从 |
| 用户通过 |
| 25种预构建角色图片之一 |
| 来自绑定集合的多个头像 |
形状由(圆形/方形/自定义)控制,尺寸由(ExtraSmall → ExtraLarge)控制。
AvatarShapeAvatarSizeDocumentation and Navigation Guide
文档与导航指南
Getting Started
入门指南
📄 Read: references/getting-started.md
- NuGet package and assembly setup
- XAML namespace declaration
- Minimal working example (Default type)
- ImageSource quick start
- Required CSS/theme imports
📄 阅读: references/getting-started.md
- NuGet包和程序集设置
- XAML命名空间声明
- 最简运行示例(Default类型)
- ImageSource快速入门
- 所需CSS/主题导入
Content Types
内容类型
📄 Read: references/content-types.md
- — zero-config avatar character
Default - —
Initials+AvatarName(Single/Double)InitialsType - —
CustomImagewith pack:// URIImageSource - — Avatar1–Avatar25 enum
AvatarCharacter - view —
Group+ member path properties + ViewModel patternGroupSource - — fully custom DataTemplate rendering
ContentTemplate
📄 阅读: references/content-types.md
- — 零配置头像角色
Default - —
Initials+AvatarName(单字符/双字符)InitialsType - — 带pack:// URI的
CustomImageImageSource - — Avatar1–Avatar25枚举
AvatarCharacter - 视图 —
Group+ 成员路径属性 + ViewModel模式GroupSource - — 完全自定义的DataTemplate渲染
ContentTemplate
Visual Styles
视觉样式
📄 Read: references/visual-styles.md
- : Circle (default), Square, Custom
AvatarShape - : ExtraSmall, Small, Medium, Large, ExtraLarge
AvatarSize - Custom shape — explicit Height, Width, CornerRadius, FontSize
- Style reuse via WPF ResourceDictionary
📄 阅读: references/visual-styles.md
- :圆形(默认)、方形、自定义
AvatarShape - :ExtraSmall、Small、Medium、Large、ExtraLarge
AvatarSize - 自定义形状 — 显式设置Height、Width、CornerRadius、FontSize
- 通过WPF ResourceDictionary复用样式
Customization
自定义设置
📄 Read: references/customization.md
- and
BorderBrushBorderThickness - — solid color
Background - Gradient background — /
LinearGradientBrushRadialGradientBrush - ,
FontFamily,FontSizefor initials textForeground
📄 阅读: references/customization.md
- 和
BorderBrushBorderThickness - — 纯色填充
Background - 渐变背景 — /
LinearGradientBrushRadialGradientBrush - 首字母文本的、
FontFamily、FontSizeForeground
Badge Integration
徽章集成
📄 Read: references/badge-integration.md
- Attaching to
SfBadgeSfAvatarView - Positioning badge with /
HorizontalPositionVerticalPosition - Status indicator pattern (online/offline dot)
📄 阅读: references/badge-integration.md
- 将附加到
SfBadgeSfAvatarView - 通过/
HorizontalPosition定位徽章VerticalPosition - 状态指示器模式(在线/离线圆点)
Quick Start Example
快速入门示例
xml
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"Display initials:
xml
<syncfusion:SfAvatarView ContentType="Initials"
AvatarName="Alex"
InitialsType="DoubleCharacter"
AvatarShape="Circle"
AvatarSize="Large" />Display a custom image:
xml
<syncfusion:SfAvatarView ContentType="CustomImage"
AvatarShape="Circle"
AvatarSize="Large"
ImageSource="pack://application:,,,/Assets/profile.png" />Display a pre-built character:
xml
<syncfusion:SfAvatarView ContentType="AvatarCharacter"
AvatarCharacter="Avatar5"
AvatarShape="Circle"
AvatarSize="Medium" />xml
xmlns:syncfusion="http://schemas.syncfusion.com/wpf"显示首字母:
xml
<syncfusion:SfAvatarView ContentType="Initials"
AvatarName="Alex"
InitialsType="DoubleCharacter"
AvatarShape="Circle"
AvatarSize="Large" />显示自定义图片:
xml
<syncfusion:SfAvatarView ContentType="CustomImage"
AvatarShape="Circle"
AvatarSize="Large"
ImageSource="pack://application:,,,/Assets/profile.png" />显示预构建角色:
xml
<syncfusion:SfAvatarView ContentType="AvatarCharacter"
AvatarCharacter="Avatar5"
AvatarShape="Circle"
AvatarSize="Medium" />Common Patterns
常见模式
Pattern 1 — Pick content type based on available data:
- Have a profile image URL → +
ContentType="CustomImage"ImageSource - Have a name string → +
ContentType="Initials"AvatarName - Need a placeholder → + choose Avatar1–Avatar25
ContentType="AvatarCharacter" - Need fully custom UI inside the avatar → with
ContentTemplateDataTemplate
Pattern 2 — Group avatar from a list:
- Bind a collection → +
ContentType="Group"GroupSource - Map member paths: ,
InitialsMemberPath,ImageSourceMemberPath,BackgroundColorMemberPathInitialsColorMemberPath
Pattern 3 — Shape + size selection:
- Profile card with circular avatar → +
AvatarShape="Circle"enumAvatarSize - Square tile avatar → +
AvatarShape="Square"enumAvatarSize - Fully custom dimensions → + explicit
AvatarShape="Custom"/Height/WidthCornerRadius
模式1 — 根据可用数据选择内容类型:
- 有资料图片URL → +
ContentType="CustomImage"ImageSource - 有名称字符串 → +
ContentType="Initials"AvatarName - 需要占位符 → + 选择Avatar1–Avatar25
ContentType="AvatarCharacter" - 需要头像内完全自定义UI → 使用和
ContentTemplateDataTemplate
模式2 — 从列表生成群组头像:
- 绑定集合 → +
ContentType="Group"GroupSource - 映射成员路径:、
InitialsMemberPath、ImageSourceMemberPath、BackgroundColorMemberPathInitialsColorMemberPath
模式3 — 形状+尺寸选择:
- 带圆形头像的资料卡片 → +
AvatarShape="Circle"枚举AvatarSize - 方形磁贴头像 → +
AvatarShape="Square"枚举AvatarSize - 完全自定义尺寸 → + 显式设置
AvatarShape="Custom"/Height/WidthCornerRadius
Key Props Reference
关键属性参考
| Property | Type | Purpose |
|---|---|---|
| | Selects rendering mode |
| | Source for initials extraction |
| | Single or double character initials |
| | Image URI for CustomImage mode |
| | Pre-built character enum (Avatar1–Avatar25) |
| | Circle / Square / Custom |
| | ExtraSmall / Small / Medium / Large / ExtraLarge |
| | Data collection for Group mode |
| | Custom template for avatar content |
| | Border color |
| | Border width |
| | Background fill (solid or gradient) |
| | Rounding for Custom shape |
| 属性 | 类型 | 用途 |
|---|---|---|
| | 选择渲染模式 |
| | 提取首字母的源数据 |
| | 单字符或双字符首字母 |
| | CustomImage模式下的图片URI |
| | 预构建角色枚举(Avatar1–Avatar25) |
| | 圆形/方形/自定义 |
| | ExtraSmall/Small/Medium/Large/ExtraLarge |
| | Group模式下的数据集合 |
| | 头像内容的自定义模板 |
| | 边框颜色 |
| | 边框宽度 |
| | 背景填充(纯色或渐变) |
| | 自定义形状的圆角 |