public static async Task <(bool Success, Champion Selected)> PickChampion(NavigationService navigator, IChampions champions, bool ban = false) { var tcs = new TaskCompletionSource <Champion>(); var win = new PickChampionPage(tcs, champions); if (ban) { win.BackImage.ImageSource = (ImageSource)Application.Current.FindResource("BgRed"); } navigator.Navigate(win); Champion selChampion; try { selChampion = await tcs.Task; } catch (TaskCanceledException) { return(false, null); } return(true, selChampion); }
public PickChampionPage(TaskCompletionSource <Champion> completion, IChampions champions) { this.PChampions = champions; InitializeComponent(); Available.IsEnabled = GameState.CanUpload; this.Completion = completion; this.DataContext = this; Search.Focus(); }