Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Parent WPF Window from a hosted usercontrol

Posted on 2014-03-12
6
Medium Priority
?
1,315 Views
Last Modified: 2014-03-23
Hi,
the situation is like this:
we have a method of a Facade (Controller) that gets a Winform User control has a parameter. The given user control is hosted in a wpf parent window.

In simple, if the user control was in the main window of the application, we have to close the MDI tab of that hosted this control.

If the control is from another window, that means that it is showen has a dialog and the parent window should close.

In simple, the question is, how do you get the parent window when you only have a winforms user control?

Would "ParentForm" work  ? but then you get a Form object that represent a Window ???
Or maybe "GetWindow" ? But then, since you don't have access to the host object, the Winform user control does not have any of this method... :P

Thank you!
0
Comment
Question by:ymazal_ca
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 16

Expert Comment

by:SriVaddadi
ID: 39927951
Is there any event on which you have to close the window
0
 

Author Comment

by:ymazal_ca
ID: 39928162
Its a generic fonction in a public [GOF] Facade that can be called from many different places.
0
 
LVL 16

Expert Comment

by:SriVaddadi
ID: 39928185
I think I m lost.  did u say u r using q facade method to load that user control or r u saying u r calling a facade metho to close the parent window?  what triggers the closing of window
0
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 

Author Comment

by:ymazal_ca
ID: 39928220
Its an application that has been developped for many years and now we are trying to transfer slowly to WPF.

There are many wiondows that are opened in a MDI style (in a devExpress Tab ).  The tab holds the hosted control in a WPF Host object that holds the Winform control.

Some times a control will be shown in a popup matter (all the same window).

In this architecture, we have a FacadeGui that has a method fncClose(Control p_Control), this Facade represent a [GRASP] controller of the Gui in general.

Anyway, in order to close a window, you call FacadeGui.getInstance().fncClose(aUserControl). In order to minimise coupling, the fncClose(...) methode does not know where the control came from and it needs to close the conained window (if its an MDI tab, then it needs to close that tab. If its a popup window, it needs to close that window).

Winform controls has the "ParentForm" property and the code can check if the given window is the main window application. In that case we check if the ParentForm is the main form and close the tab or the poup window other wise.

In simple, we have a winform user control in a host object in wpf and we need to find its WPF "window" to close it.
0
 

Accepted Solution

by:
ymazal_ca earned 0 total points
ID: 39937866
Here is what was done:
in the Application class, there is all the list of windows. when the control is send to the Facade, each window is examined if he has a host that hold this control.

If its the main window, then the list of tabs (mdi windows in Tabs) was examin and the proper tab was closed. To bad you can't just get the window directly from the winform control in WPF...
0
 

Author Closing Comment

by:ymazal_ca
ID: 39948412
There was no other solutions and the question has been abandoned for more couple of days now.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question