Quantcast
Channel: patterns & practices: Prism
Viewing all articles
Browse latest Browse all 1878

New Post: Issue in getiing the view name for showing the dialog in wpf prism

$
0
0
Hi Krishna,

I am not aware of how your problem with the modal dialog is related to the one with retrieving the view from the region; however, I will try to provide an answer for both of them.

Regarding the first problem (of showing a modal dialog) you have several approaches you can use to show a dialog window. One of them is using the WindowDialogActivationBehavior included in the Stock Trader RI which creates a region that acts as a popup when a view is injected in it. Another approach is to use a PopupWindowAction to show a dialog in response to an InteractionRequest. You can find a modified version a PopupWindowAction in the following blog post:
Regarding the second problem, a possible approach to obtain the view corresponding to your view model from a region is to iterate over the views until you find one that is using the view model as its DataContext. For example, you could implement a logic similar to the following one in the view model in order to obtain the view from a specific region:
object myView = null;

foreach (var view inthis.regionManager.Regions["RegionName"].Views)
{
    FrameworkElement element = view as FrameworkElement;
    if (element != null&& element.DataContext == this)
    {
        myView = view;
     }
}
I hope this help,

Damian Cherubini
http://blogs.southworks.net/dcherubini

Viewing all articles
Browse latest Browse all 1878

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>