<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
<StackPanel>
<Button Content="手机网络" Click="OnClick"/>
<Button Content="飞行模式" Click="OnClick"/>
<Button Content="Wi-Fi网络" Click="OnClick"/>
<Button Content="蓝牙" Click="OnClick"/>
</StackPanel>
</Grid>
private void OnClick(object sender, RoutedEventArgs e)
{
Button btn = e.OriginalSource as Button;
if (btn != null)
{
ConnectionSettingsTask MySettin = new ConnectionSettingsTask();
// 判断网络设置类型
string cnType = btn.Content as string;
switch (cnType)
{
case "手机网络":
MySettin.ConnectionSettingsType = ConnectionSettingsType.Cellular;
break;
case "飞行模式":
MySettin.ConnectionSettingsType = ConnectionSettingsType.AirplaneMode;
break;
case "Wi-Fi网络":
MySettin.ConnectionSettingsType = ConnectionSettingsType.WiFi;
break;
case "蓝牙":
MySettin.ConnectionSettingsType = ConnectionSettingsType.Bluetooth;
break;
default:
break;
}
MySettin.Show();
}
}