Reputation: 10296
I would like to develop a small reusable component that closely resembles BTProgressHud for Monotouch. But I'm currently stuck on how to inject the overlay into the visual tree without interfering with the page content.
Update:
After experimenting around for a bit, I came up with the idea to in order to be able to decouple the overlays from the page content to change the Window Content from the a Frame to a Grid which can host both the root frame and any notification elements.
App.xaml.cs
protected override async void OnLaunched(LaunchActivatedArgs args)
{
Grid rootGrid = Window.Current.Content as Grid;
if(rootGrid == null)
{
var rootFrame = new Frame();
rootGrid = new Grid();
rootGrid.Children.Add(rootFrame);
Window.Current.Content = rootGrid;
}
}
ProgressHud.cs
public static class ProgressHud
{
static void Show(string msg)
{
Grid rootGrid = Window.Current.Content as Grid;
// just for testing the concept
rootGrid.Children.Add(new ProgressRing { IsActive = true };
}
}
Could anyone confirm wether changing the Window.Content root from a frame to a grid could cause unwanted side effects?
Upvotes: 0
Views: 162
Reputation: 15237
Depends somewhat on what the rest of your pages are like, but an overlay control like that can usually just be put inside your main container on the page (whether its a Grid or Canvas or whatever) as the last element (so it'll be top-most in z-order) and then just set to be not visible/collapsed (until needed). it won't interfere with your other content while it is collapsed.
Upvotes: 1