如何绑定到IsExpanded属性 - 保持TreeView的扩展状态?

时间:2017-04-03 14:41:59

标签: xaml winrt-xaml-toolkit

在ViewModel中,我定义了一个bool ShouldExpand属性,从TreeView的itemcontainerstyle绑定到它 - 它不起作用。

这个答案(WinRT XAML Toolkit TreeView Save state)会回答我的问题,但不起作用......

是否有WORKING代码段?

DispatchQueue.main.async(execute: {
    yourPicker.countDownDuration = TimeInterval() 
})

XAML:

public class AgendaItemTreeView : ViewModelBase
{
    private string _title;
    private Visibility _documentGridVisibility = Visibility.Collapsed;
    private bool _shouldExpand;

    // Binding property - to display in a TreeView
    public string Title
    {
        get { return _title; }
        set { Set(ref _title, value); }
    }

    // To expand/collapse documents GridView
    public Visibility DocumentGridVisibility
    {
        get { return _documentGridVisibility; }
        set { Set(ref _documentGridVisibility, value); }
    }

    // Property to expand/collapse a node in a TreeView - does not work!
    public bool ShouldExpand
    {
        get { return _shouldExpand; }
        set { Set(ref _shouldExpand, value); }
    }

    // Nested agenda items
    public ObservableCollection<AgendaItemTreeView> AgendaItems { get; set; } = new ObservableCollection<AgendaItemTreeView>();

    // Documents of current agenda item
    public ObservableCollection<DocumentViewModel> Documents { get; set; } = new ObservableCollection<DocumentViewModel>();

    public DocumentViewModel SelectedItem { get; set; }

    public AgendaItemTreeView(AgendaItem agendaItem, string selectedTitle = "")
    {
        // Constructor populating the nested AgendaItem & Documents
    }
}

0 个答案:

没有答案