Binding to a single element inside a CompositeCollection

前端 未结 4 817
清酒与你
清酒与你 2020-12-11 05:58

I am trying to produce a list of servers for browsing on a network such that it produces a tree view which looks like this:

-Local Server
 - Endpoint 1
 - En         


        
4条回答
  •  盖世英雄少女心
    2020-12-11 06:33

    Can't you just expose a new collection from your ViewModel that the tree can bind to?

    Something like:

    public Server LocalServer;
    public ObservableCollection RemoteServers;
    
    public IEnumerable ServerTree { return new[] { LocalServer, RemoteServers } }
    

    After all your ViewModel is a ViewModel. It should be exposing exactly what is needed by the view.

提交回复
热议问题