As a result, I've updated my sample to not require wrapping the root level PhoneApplicationFrame with a Grid. It turns out, most pages already have a Grid as their LayoutRoot element and you can just pass this in to a new RootPaneBusyService and use it in the same manner. So instead of passing the App.Current.RootVisual as Grid, we pass the LayoutRoot.
protected override void OnNavigatedTo( System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
var busyServ = new RootPanelBusyService(this.LayoutRoot);
this.DataContext = new MainPageVM(busyServ);
}
I've also updated the CreateBusyElement method to detect how many rows and columns are in the passed in root visual and set the ColumnSpan and RowSpan accordingly.
// Set the row and column span's if the root is a grid.
if (rootVisual is Grid)
{
var gridRoot = rootVisual as Grid;
int rowSpan = 1;
if (gridRoot.RowDefinitions != null)
rowSpan = gridRoot.RowDefinitions.Count + 1;
int columnSpan = 1;
if (gridRoot.ColumnDefinitions != null)
columnSpan = gridRoot.ColumnDefinitions.Count + 1;
Grid.SetRowSpan(root, rowSpan);
Grid.SetColumnSpan(root, columnSpan);
}
Download the updated sample
Now Playing: The Roots - Get Busy

No comments:
Post a Comment