private async void ConnectToWifi(WiFiAvailableNetwork network, PasswordCredential credential, CoreDispatcher dispatcher) { var didConnect = credential == null? networkPresenter.ConnectToNetwork(network, AutomaticallyChecked) : networkPresenter.ConnectToNetworkWithPassword(network, AutomaticallyChecked, credential); await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { SwitchToItemState(network, "WifiConnectingState", false); }); //string nextState = (await didConnect) ? "WifiConnectedState" : "InitialState"; await dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { SwitchToItemState(ConnectedNetwork, "InitialState", false); }); if (await didConnect) { ConnectedNetwork = network; WifiListSources.Remove(ConnectedNetwork); WifiListSources.Insert(0, ConnectedNetwork); SwitchToItemState(ConnectedNetwork, "WifiConnectedState", true); } else { ConnectedNetwork = null; WifiSelected = null; } }