Quantcast
Channel: Jacob Gable's Posterous
Viewing all articles
Browse latest Browse all 17

Updated Win Phone 7 Busy Service That Does Not Change RootVisual

$
0
0

Evidently, you are not supposed to change the RootVisual in a Win Phone 7 application.  There was a forum post posed by Matt Hidinger and answered by Peter Torr about Changing the RootVisual that indicates this might cause problems during the approval process.

Media_http1bpblogspot_epnhj

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

Permalink | Leave a comment  »


Viewing all articles
Browse latest Browse all 17

Trending Articles