XamDataGrid columns
-
Hello, I am writing my app using MVVM pattern. I have a XamDataGrid and i need to display in it my ViewModels. I have a collection of VMs so each VM should be a row in the DataGrid. Also each VM has a child VM that has collection of VMs. Each such VM contains 3 properties- Field, Value and operator. I need the DataGrid to have dynamic fields according to the fields i have (in the collection of "small" VMs). each cell will contain the right value from the small VM under the right field . The operator value should be displayed in another operator column. All operators are the same for the VMs related to same row in the DataGrid. Currently i did it using dependency property- i bind the collection of VMs and than build a DataTable with dynamic columns and set is as DataSource of the dataGrid. The thing is that it is fine if my DataGrid is read-only. But i need an option to change the DataGrid values . If i will do it with current code (with dependency property) i don't know what VM to change (because the DataGrid cell is not bind to any object). How can i still solve this so it will work with binding?
-
Hello, I am writing my app using MVVM pattern. I have a XamDataGrid and i need to display in it my ViewModels. I have a collection of VMs so each VM should be a row in the DataGrid. Also each VM has a child VM that has collection of VMs. Each such VM contains 3 properties- Field, Value and operator. I need the DataGrid to have dynamic fields according to the fields i have (in the collection of "small" VMs). each cell will contain the right value from the small VM under the right field . The operator value should be displayed in another operator column. All operators are the same for the VMs related to same row in the DataGrid. Currently i did it using dependency property- i bind the collection of VMs and than build a DataTable with dynamic columns and set is as DataSource of the dataGrid. The thing is that it is fine if my DataGrid is read-only. But i need an option to change the DataGrid values . If i will do it with current code (with dependency property) i don't know what VM to change (because the DataGrid cell is not bind to any object). How can i still solve this so it will work with binding?
Don't use dynamic columns. You should template out each column and set up the binding for each one seperately.
Computers have been intelligent for a long time now. It just so happens that the program writers are about as effective as a room full of monkeys trying to crank out a copy of Hamlet.
-
Don't use dynamic columns. You should template out each column and set up the binding for each one seperately.
Computers have been intelligent for a long time now. It just so happens that the program writers are about as effective as a room full of monkeys trying to crank out a copy of Hamlet.
Right, But i don't know the number of fields i have.