-1
打开链接在我的Windows手机应用程序,我使用的RichTextBox元素取消浏览器
我有它的超链接,当它的用户点击有一个对话框:你想打开exteranl浏览器此链接。如果用户说不,则不应打开外部浏览器。我取消导航,但无论如何 - 外部浏览器打开。我如何取消浏览器中的开放链接?
//Constructor
static Helper()
{
var phoneApplicationFrame = Application.Current.RootVisual as PhoneApplicationFrame;
if (Application.Current.RootVisual as PhoneApplicationFrame != null)
{
phoneApplicationFrame.Navigating += new NavigatingCancelEventHandler(NavigationService_Navigating);
}
}
link.Foreground = new SolidColorBrush(Colors.Blue);
link.MouseOverForeground = new SolidColorBrush(Colors.Blue);
link.TargetName = "_blank";
var linkText = new Run() { Text = linkDesc };
link.Inlines.Add(linkText);
link.Click += new RoutedEventHandler(NavidateTo);
private static void NavidateTo(object sender, RoutedEventArgs routedEventArgs)
{
if (MessageBox.Show(
Constants.BrowserNavigating,
"",
MessageBoxButton.OKCancel) == MessageBoxResult.Cancel)
{
StateManager.Set("ExternalBrowser", "true");
}
else
{
StateManager.Set("Browser", "true");
}
}
public static void NavigationService_Navigating(object sender, NavigatingCancelEventArgs e)
{
var res = StateManager.Get("ExternalBrowser");
if (res != null)
{
StateManager.Remove("ExternalBrowser");
e.Cancel = true;
}
}
我们不能告诉你最新的代码有问题,如果你不向我们展示你的代码.. – RhysW
[RichTextBox中如何取消导航]的可能重复(http://stackoverflow.com/questions/10547834/how-cancel-navigation -in-RichTextBox中) – CharlesB