Yes this is possible, use the Windows.Devices.WiFi.WiFiAdapter API take a look at this tutorial:
https://developer.microsoft.com/en-us/windows/iot/samples/wificonnector
In short (taken and edited from the tutorial):
Make sure you add the correct device capability to your appx manifest:
<DeviceCapability Name="wifiControl" />
After that you can use the following code to connect to wifi;
enum WifiConnectResult
{
WifiAccessDenied,
NoWifiDevice,
Success,
CouldNotConnect,
SsidNotFound,
}
private async Task<WifiConnectResult> ConnectWifi(string ssid, string password)
{
if (password == null)
password = "";
var access = await WiFiAdapter.RequestAccessAsync();
if (access != WiFiAccessStatus.Allowed)
{
return WifiConnectResult.WifiAccessDenied;
}
else
{
var allAdapters = await WiFiAdapter.FindAllAdaptersAsync();
if (allAdapters.Count >= 1)
{
var firstAdapter = allAdapters[0];
await firstAdapter.ScanAsync();
var network = firstAdapter.NetworkReport.AvailableNetworks.SingleOrDefault(n => n.Ssid == ssid);
if (network != null)
{
WiFiConnectionResult wifiConnectionResult;
if (network.SecuritySettings.NetworkAuthenticationType == Windows.Networking.Connectivity.NetworkAuthenticationType.Open80211)
{
wifiConnectionResult = await firstAdapter.ConnectAsync(network, WiFiReconnectionKind.Automatic);
}
else
{
// Only the password potion of the credential need to be supplied
var credential = new Windows.Security.Credentials.PasswordCredential();
credential.Password = password;
wifiConnectionResult = await firstAdapter.ConnectAsync(network, WiFiReconnectionKind.Automatic, credential);
}
if (wifiConnectionResult.ConnectionStatus == WiFiConnectionStatus.Success)
{
return WifiConnectResult.Success;
}
else
{
return WifiConnectResult.CouldNotConnect;
}
}
else
{
return WifiConnectResult.SsidNotFound;
}
}
else
{
return WifiConnectResult.NoWifiDevice;
}
}
}