惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
腾讯CDC
The Cloudflare Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
GbyAI
GbyAI
D
Docker
W
WeLiveSecurity
L
LINUX DO - 最新话题
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Hugging Face - Blog
Hugging Face - Blog
Recent Announcements
Recent Announcements
Application and Cybersecurity Blog
Application and Cybersecurity Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
S
Secure Thoughts
The Last Watchdog
The Last Watchdog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Y
Y Combinator Blog
月光博客
月光博客
N
News | PayPal Newsroom
WordPress大学
WordPress大学
Webroot Blog
Webroot Blog
Cloudbric
Cloudbric
F
Full Disclosure
有赞技术团队
有赞技术团队
Security Archives - TechRepublic
Security Archives - TechRepublic
T
Tailwind CSS Blog
D
DataBreaches.Net
T
The Blog of Author Tim Ferriss
P
Privacy & Cybersecurity Law Blog
H
Hacker News: Front Page
T
Troy Hunt's Blog
SecWiki News
SecWiki News
美团技术团队
博客园 - 司徒正美
S
Schneier on Security
P
Palo Alto Networks Blog
宝玉的分享
宝玉的分享
Attack and Defense Labs
Attack and Defense Labs
大猫的无限游戏
大猫的无限游戏
Google DeepMind News
Google DeepMind News
PCI Perspectives
PCI Perspectives
Cyberwarzone
Cyberwarzone
MongoDB | Blog
MongoDB | Blog
B
Blog RSS Feed
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
IT之家
IT之家
V2EX - 技术
V2EX - 技术
Vercel News
Vercel News
C
CERT Recently Published Vulnerability Notes

博客园 - dalgleish

C# Avalonia 23- OpenGL- 例子通用类 C# Avalonia 22- SoundAndVideo- SpeechVoiceTest C# Avalonia 22- SoundAndVideo- SpeechRecognition C# Avalonia 22- SoundAndVideo- SpeechSynthesis C# Avalonia 22- SoundAndVideo- CodePlayback C# Avalonia 22- SoundAndVideo- SoundPlayerTest C# Avalonia 21- MenusAndToolbars- RibbonTest C# Avalonia 21- MenusAndToolbars- ProportionalStatusBar C# Avalonia 21- MenusAndToolbars- BasicToolbar C# Avalonia 21- MenusAndToolbars- ToolBar/Ribbon开源项目介绍和修复 C# Avalonia 21- MenusAndToolbars- SidebarMenu C# Avalonia 21- MenusAndToolbars- MixedMenus C# Avalonia 20 - WindowsMenu- 魔改Hyperlink - 使用例子 C# Avalonia 20 - WindowsMenu- 魔改Hyperlink C# Avalonia 20 - WindowsMenu- WebViewTest C# Avalonia 20 - WindowsMenu- WebView C# Avalonia 20 - WindowsMenu- ModernWindowTest C# Avalonia 20 - WindowsMenu- ModernWindow C# Avalonia 20 - WindowsMenu- TransparentWithShapes C# Avalonia 20 - WindowsMenu- TransparentBackground C# Avalonia 20 - WindowsMenu- OpenFileTest C# Avalonia 20 - WindowsMenu- SavePostion C# Avalonia 20 - WindowsMenu- CenterScreen C# Avalonia 19- DataBinding- DataGridGrouping C# Avalonia 19- DataBinding- DirectoryTreeView C# Avalonia 19- DataBinding- CustomListViewTest
C# Avalonia 19- DataBinding- BoundTreeView
dalgleish · 2026-02-16 · via 博客园 - dalgleish

BoundTreeView.axaml代码

<Window xmlns="https://github.com/avaloniaui"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        Height="300" Width="300"
        xmlns:local="using:AvaloniaUI"
        xmlns:data="using:AvaloniaUI.Demos.Book._19.StoreDatabase"
        x:Class="AvaloniaUI.BoundTreeView"
        Title="BoundTreeView">

    <TreeView Name="treeCategories" x:DataType="local:BoundTreeView"
              Margin="5"
              ItemsSource="{Binding Categories}">
        
        <TreeView.DataTemplates>

            <TreeDataTemplate x:DataType="data:Category"
                              ItemsSource="{Binding Products}">
                <TextBlock Text="{Binding CategoryName}" />
            </TreeDataTemplate>

            <TreeDataTemplate x:DataType="data:Product">
                <TextBlock Text="{Binding ModelName}" />
            </TreeDataTemplate>

        </TreeView.DataTemplates>
    </TreeView>
</Window>

BoundTreeView.axaml.cs代码

using Avalonia;
using Avalonia.Controls;
using Avalonia.Markup.Xaml;
using AvaloniaUI.Demos.Book._19.StoreDatabase;
using System.Collections.ObjectModel;

namespace AvaloniaUI;

public partial class BoundTreeView : Window
{
    private StoreDb1 db = new StoreDb1();
    public ObservableCollection<Category> Categories { get; }
    public BoundTreeView()
    {
        InitializeComponent();
        Categories = db.GetCategoriesAndProducts();
        this.DataContext = this;
    }
}

运行效果

image