开发者

C#,WPF integrated user control

Got a winform in project A (Main project) and which hosts a wpf user control and is maintained under different project called B

On click of a button on user control ,I wanted to query server which is in project "C" and retrieve data and show it on hosted wpf user control. I kn开发者_如何学JAVAow its a bad coding practice to put a reference to s project "C" in project B which includes only custom controls .Any alternative thots would be appreciated...


To minimize project dependencies, create an interface in your control project (B) that reflects the operations your control requires.

Implement a class in your client (A) project that implements this interface (which will obtain the information you need from your data project (C) and pass it back through the interface method).

Pass the service class (implementing the interface) constructed in A to your control B when you initialize the control.


You make another project that is just a class library that can be shared across all three projects. You'll put the interfaces and/or the class implementations that need to be shared between the projects in the class library and then just use those in the server and the user-control projects.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜