Hi
I'm using the 9.2.20092.2014 version of the xamWebTileView.
In my shell.xaml I have a region inside a xamWebTileView like this :
<igTileView:XamWebTileView RowsInPage="2"
ColumnsInPage="2">
<igTileView:TilePane Header="Sales By Department/Category/Vendor">
<ContentControl x:Name="SalesRegion"
Regions:RegionManager.RegionName="SalesRegion" />
</igTileView:TilePane>
</igTileView:XamWebTileView>
When I run the application, in the module definition when I am trying to inject a view into the region, the region manager does not contain the region.
IRegion detailsRegion = this.regionManager.Regions["SalesRegion"];
Results in exception : The region manager does not contain the SalesRegion region.
If the region is not contained in a xamWebTileView then the region is contained in the region manager.
This is a pain because I can't use view injection when the region is inside a xamWebTileView. Any ideas? am i doing something wrong or is something missing from the xamWebTileView that needs fixing for it to be compatible with Prism's RegionManager?
Thanks
Kevin
Hi Kevin,I've checked how the RegionManager works. I'm using the ViewInjectionComposition sample and the problem is that we cannot override the logical tree in Silverlight controls, look at FindRegionManager method implementation in RegionManagerRegistrationBehavior.cs.So, you have two options:1. To modify FindRegionManager method to use the visual tree when the parent is nullYou have to modify the UnityBootstrapper.cs to postpone the UpdateRegions when the visual tree is ready, you can use the LayoutUpdated event.2. Move your tile pane to the root grid and add it to the tile view in loaded eventhandlerMarin
Thanks for your reply Marinii,
I can see where your coming from with both options however I'm struggling to get either to work.
1. In the FindRegionManager method I'm trying to get the parent of the Tilepane and it is always null regardless of wether i do this:
FrameworkElement frameworkElement = dependencyObject as FrameworkElement;
if (frameworkElement != null)
{
parent = frameworkElement.Parent;
}
or this:
parent = System.Windows.Media.VisualTreeHelper.GetParent(dependencyObject);
Is this the correct way to use the VisualTree?
2. If I move the Tilepane to the root then yes they are in the RegionManger as their parent is now the Layoutroot grid. But when I try and move them to the Tileview in the shell loaded event like this:
this.LayoutRoot.Children.Remove(this.DonutTile);
this.ChartTileView.Items.Add(this.DonutTile);
The regions are no longer in the RegionManager when the module initializes.
Is this the best way to move the Tilepanes?
Thanks again
Hi Kevin,1. FindRegionManager modification:FrameworkElement frameworkElement = dependencyObject as FrameworkElement;if (frameworkElement != null){ parent = frameworkElement.Parent;}if (parent == null){ parent = System.Windows.Media.VisualTreeHelper.GetParent(dependencyObject);}UtilityBootsraper Run method changes:DependencyObject shell = this.CreateShell();_shell = shell as FrameworkElement;_shell.LayoutUpdated += Shell_LayoutUpdated;return;// move this code to the Shell_LayoutUpdated//if (shell != null)//{//RegionManager.SetRegionManager(shell, this.Container.Resolve<IRegionManager>());...FrameworkElement _shell = null;void Shell_LayoutUpdated(object sender, EventArgs e){ if (_shell != null) { DependencyObject shell = _shell; // sender as DependencyObject; if (shell != null) { RegionManager.SetRegionManager(shell, this.Container.Resolve<IRegionManager>()); RegionManager.UpdateRegions(); } ILoggerFacade logger = this.LoggerFacade; logger.Log("Initializing modules", Category.Debug, Priority.Low); this.InitializeModules(); logger.Log("Bootstrapper sequence completed", Category.Debug, Priority.Low); _shell.LayoutUpdated -= Shell_LayoutUpdated; _shell = null; }}2. My code is:private void TilePane_Loaded(object sender, RoutedEventArgs e){ TilePane tile = sender as TilePane; Grid parent = tile.Parent as Grid; if (parent != null) { parent.Children.Remove(tile); tileView1.Items.Add(tile); } tile.Loaded -= TilePane_Loaded;}Marin