我有一個HyperlinkButton。當我點擊它時,它會啓動帶有鏈接的互聯網瀏覽器,因爲他應該這樣做。點擊後取消HyperlinkButton事件
我想在某些情況下取消這個HyperlinkButton事件。
例如:在hyperlinkbutton
- 用戶點擊
- 應用程序檢查互聯網連接
- 如果沒有互聯網連接不啓動互聯網瀏覽器, 停留在應用
示例代碼(類似的東西):
<Page x:Class="App1.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="using:App1" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
<Grid>
<HyperlinkButton NavigateUri="http://stackoverflow.com/" Content="GO TO WEBPAGE" Click="HyperlinkButton_Click_1" />
</Grid>
</Page>
private void HyperlinkButton_Click_1(object sender, RoutedEventArgs e)
{
var connectionProfile = NetworkInformation.GetInternetConnectionProfile();
if (connectionProfile == null || connectionProfile.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.LocalAccess || connectionProfile.GetNetworkConnectivityLevel() == NetworkConnectivityLevel.None)
{
NO INTERNET, CANCEL THE EVENT!!!!!!!!
}
}
那麼,如何取消HyperlinkButton事件後點擊?
+1供參考。 – Jonast92