PrismLibrary / Prism

Prism is a framework for building loosely coupled, maintainable, and testable XAML applications in WPF, Xamarin Forms, and Uno / Win UI Applications..
Other
6.34k stars 1.64k forks source link

Region missing in regionmanger (Prism WPF 6.3) #1570

Closed GioviQ closed 6 years ago

GioviQ commented 6 years ago

I have a Prism WPF 6.3 application using a main menu copied from the following xaml https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/blob/master/MainDemo.Wpf/MainWindow.xaml

I put a region in ListBox at line 47. The region works as expected (I see the registered views), but I cannot find it in region manager.

After some test I suspect the issue is because the region is nested in .

For example I have another region in ContentControl at line 88 and it is present in region manager.

Why region is not in region manager?

brianlagunas commented 6 years ago

I have no experience with the MaterialDesign system you are trying to use. As that is a custom UI kit, I cannot officially support it. However, I can say that I guess that DialogHost is not part of the visual tree and therefore the region will not be created automatically. You will most likely have to attach the region manager in code-behind manually. That in addition to the fact that you didn't provide the required reproduction application, I am closing this issue.

Jesus805 commented 6 years ago

@brianlagunas Apologies for bringing up this old issue but I am also having this problem and was hoping I can receive a pointer on how to workaround this issue. I'm unable to perform view injection because the region does not exist in IRegionManager.Regions.

https://github.com/Jesus805/PrismxMaterialDesign

brianlagunas commented 6 years ago

@Jesus805 As I said in the previous post, you will have to attach the region manager in code-behind manually. Also, don't use the ServiceLocator. I don't know where you learned to set up your application like that, but it's not the correct way. Check out these samples: https://github.com/PrismLibrary/Prism-Samples-Wpf

Jesus805 commented 6 years ago

@brianlagunas I'm not sure how to do that... is there a link to an example that I can look at? I'm still a noob at prism. Also, most of my setup code is from your pluralsight videos, which I moved from a bootstrapper.cs to App.cs in order to use the new PrismApplication. All of those Prism samples aren't using the new PrismApplication so I'm not sure how to properly set it up. I'm honestly not sure where I got that ServiceLocator line of code. ¯\_(ツ)_/¯ but I changed it, thanks.

brianlagunas commented 6 years ago

It's just an attached property. It works like every attached property in WPF. Give your element a x:Name, and the use the attached property in code-behind.

Jesus805 commented 6 years ago

I was able to get this to work. @GioviQ Refer to this page to register the DrawerHost Contents to the RegionManager. https://github.com/steve600/PrismMahAppsSample/wiki/Part-2:-Regions-and-RegionManager I'll also update my github repository with this solution.

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.