Windows Phone アプリケーションの RichTextBox のコードには、次のものがあります。
var link = new Hyperlink();
if (!string.IsNullOrEmpty(linkUrl))
{
link.NavigateUri = new Uri(linkUrl);
}
link.Foreground = new SolidColorBrush(Colors.Blue);
link.TargetName = "_blank";
var linkText = new Run() { Text = linkDesc };
link.Inlines.Add(linkText);
link.Click += new RoutedEventHandler(NavidateTo);
paragraph.Inlines.Add(link);
private static void NavidateTo(object sender, RoutedEventArgs routedEventArgs)
{
if (MessageBox.Show(
Constants.BrowserNavigating,
"",
MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
{
//cancel Navigation
}
else
{
StateManager.Set("Browser", "true");
}
}
NavidateTo メソッドでナビゲーションをキャンセルするにはどうすればよいですか?
アップデート
private static void NavidateTo(オブジェクト送信者, RoutedEventArgs routedEventArgs) {
if (MessageBox.Show(
Constants.BrowserNavigating,
"",
MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
{
//cancel Navigation
var phoneApplicationFrame = Application.Current.RootVisual as PhoneApplicationFrame;
if (Application.Current.RootVisual as PhoneApplicationFrame != null)
phoneApplicationFrame.Navigating += new NavigatingCancelEventHandler(NavigationService_Navigating);
}
else
{
StateManager.Set("Browser", "true");
}
}
public static void NavigationService_Navigating(object sender, NavigatingCancelEventArgs e)
{
{
e.Cancel = true;
}
}
これは役に立たない