如何将UWP中的树视图绑定到ViewModel? [英] How to bind a treeview in UWP to a ViewModel?

查看:106
本文介绍了如何将UWP中的树视图绑定到ViewModel?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在UWP工作,我需要创建一个TreeView来分层存储服务查询.例子:,绑定到TreeView和TreeViewItem上ItemsItem属性的数据在Insider Preview构建和SDK中.您可以按照文档使用数据绑定的树视图部分来实现此功能,但是您应该安装Example I have

I keep the information in a public ObservableCollection <Model> name_of_object {get; set; } = new ObservableCollection <Model> ();

But I create the TreeView in the XAML and I do not see any way to do a Binding to the "SelectedItem" and "ItemSource" or any way to bring a query.

Tried this solution: Recursive XAML binding data templates on the Universal Windows Platform

and I made it work with a query, it works for me, but nevertheless I need to manage other fields and I would like to be able to handle the one in this example:

Windows Dev Centre: Tree View

I want this, but with Bindings to ViewModel in UWP:

解决方案

As the document you refered about TreeView, the Data binding to the ItemsSource property on TreeView and TreeViewItem is in Insider Preview build and SDK. You can follow the document Tree view using data binding part to achieve this function, but you should install the latest Windows 10 Insider Preview build and SDK, target you app on the insider preview build and test it in the insider preview build OS device.

这篇关于如何将UWP中的树视图绑定到ViewModel?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆