Skip to content

Instantly share code, notes, and snippets.

@mattleibow
Last active August 29, 2015 14:19
Show Gist options
  • Save mattleibow/2cef8c6c4d62bad26275 to your computer and use it in GitHub Desktop.
Save mattleibow/2cef8c6c4d62bad26275 to your computer and use it in GitHub Desktop.
Microsoft Band SDK - Navigation Issues
// The code that shows the confirmation popup/page
public async Task<Boolean> GetAddTileConsentAsync(BandTile tile, CancellationToken token)
{
Boolean flag;
CoreApplicationView mainView = CoreApplication.MainView;
if (mainView != null)
{
CoreWindow coreWindow = mainView.CoreWindow;
if (coreWindow != null)
{
TaskCompletionSource<Boolean> taskCompletionSource = null;
ConfiguredTaskAwaitable configuredTaskAwaitable = coreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => {
token.ThrowIfCancellationRequested();
Window current = Window.Current;
if (current != null)
{
Frame content = current.Content as Frame;
if (content != null)
{
taskCompletionSource = new TaskCompletionSource<Boolean>();
content.Navigate(typeof(T), new AddTileViewModel(tile, taskCompletionSource));
}
}
}).AsTask().ConfigureAwait(false);
await configuredTaskAwaitable;
if (taskCompletionSource != null)
{
flag = await taskCompletionSource.get_Task().ConfigureAwait(false);
return flag;
}
}
}
flag = false;
return flag;
}
// the code that handles the user's response
if (base.Frame.CanGoBack)
{
base.Frame.GoBack();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment