Query-based master-detail relationship and WPF

Query-based master-detail relationship and WPF

Postby stj » Wed 03 Sep 2008 13:45

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?
stj
 
Posts: 3
Joined: Wed 03 Sep 2008 13:14

Postby Shalex » Thu 11 Sep 2008 13:36

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.
Shalex
Devart Team
 
Posts: 7460
Joined: Thu 14 Aug 2008 12:44

Postby stj » Wed 17 Sep 2008 12:55

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;
stj
 
Posts: 3
Joined: Wed 03 Sep 2008 13:14

Postby Shalex » Wed 17 Sep 2008 16:03

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.
Shalex
Devart Team
 
Posts: 7460
Joined: Thu 14 Aug 2008 12:44

Postby stj » Wed 17 Sep 2008 19:04

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?
stj
 
Posts: 3
Joined: Wed 03 Sep 2008 13:14


Return to dotConnect for Oracle