Page 1 of 1
Query-based master-detail relationship and WPF
Posted: Wed 03 Sep 2008 13:45
by stj
Can I use query-based master-detail relationship in the WPF application?
The problem is that OracleDataTable's Owner property accepts form that the component resides on. It seems like it accepts only WinForms - I cannot set it to C# class/WPF Window.
Is there an interface I could implement to make any C# class acceptable for the Owner property?
Posted: Thu 11 Sep 2008 13:36
by Shalex
The Owner property is used for configuration of master-detail relationship in WinForms design time, WPF design time is not supported now. But you can make data binding manually.
Posted: Wed 17 Sep 2008 12:55
by stj
Shalex,
I'm trying to make all data binding manually.
I've tested query-based master-detail relationship using WinForms. I've put two data grids (DataGridView) on form and run example from documentation. Everything worked fine until I commented setting Owner properties. Detail grid is not showing any data when Owner properties are not set.
Do you now how can I make it work without setting Owner properties?
My source code:
OracleConnection connection = new OracleConnection("User Id=scott;Password=tiger;Server=orcl");
connection.Open();
OracleDataTable deptTable = new OracleDataTable("SELECT * FROM DEPT", connection);
OracleDataTable empTable = new OracleDataTable("SELECT * FROM EMP", connection);
empTable.ParentRelation.ParentTable = deptTable;
empTable.ParentRelation.ParentColumnNames = new string[] { "deptno" };
empTable.ParentRelation.ChildColumnNames = new string[] { "deptno" };
//deptTable.Owner = this;
//empTable.Owner = this;
deptTable.Open();
empTable.Open();
deptDataGrid.DataSource = deptTable;
empDataGrid.DataSource = empTable;
Posted: Wed 17 Sep 2008 16:03
by Shalex
To make child table adjust its rows according to the current position in the parent table you should:
1. Set the ParentRelation property (ParentTable, ParentColumnNames and ChildColumnNames) of empTable.
2. Set deptTable.Owner = this. As a result, deptTable will track the events only from the specified Form.
Otherwise, you can use relations in DataSet for the same purpose.
Posted: Wed 17 Sep 2008 19:04
by stj
Thanks for reply.
My original problem was how to use query-based master-detail relationship in the WPF application. In WPF window I cannot set deptTable.Owner = this. I've created small WinForms example only to test, if Owner can be not set when I don't use design time features (like you suggested in previous reply).
Does it mean that query-based master-detail relationship works only with WinForms? If not, do you have an example how to use it in WPF?