绑定TreeTableView

时间:2015-07-30 13:27:03

标签: data-binding binding javafx javafx-8

如何绑定TreeTableView?这给了我一个错误:

tblTreeView.rootProperty().bind(model.transactionProperty());

其中transactionProperty()

public SimpleListProperty<Document> transactionsProperty() {
        if(transactions == null){
            transactions = new SimpleListProperty<>();
        }
        return transactions;
    }

1 个答案:

答案 0 :(得分:0)

The given expression is never of the provided ('System.Collections.Generic.List<Foo>') type 的{​​{3}}是public class Foo { public int SomeVar { get; set; } } public class MainWindow : Window { public MainWindow () { List<Foo> Foos = new List<Foo> (); Foos.Add (new Foo ()); Foos.Add (new Foo ()); DataGrid SomeDataGrid = new DataGrid (); SomeDataGrid.ItemsSource = Foos; Type DataGridType = SomeDataGrid.ItemsSource.GetType (); if (DataGridType is List<Foo>) //< Error { // do stuff } } } TreeTableView此TreeTableView中使用的TreeItem实例的类型)

ObjectProperty<TreeItem<S>>

它可以绑定到S

TreeTableView<Document> treeTable = new TreeTableView<>();
ObjectProperty<TreeItem<Document>> rootProperty = treeTable.rootProperty();