我将WPF WebBrowser控件拖到我的Blend项目中,然后将源指定为HTML5页面。我想在我的WPF应用程序中使用LobsterPot HTML5 PivotViewer(url:LobsterPot HTML5 PivotViewer)。
页面加载然后我在浏览器顶部收到一条通知,说明活动内容已被阻止,当我点击“允许”时,屏幕仍为空白。屏幕上不显示任何内容。任何人都可以指导我并解释我哪里出错......
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="CheckLobster.MainWindow"
x:Name="Window"
Width="640" Height="480" UseLayoutRounding="True" WindowStartupLocation="CenterScreen" WindowState="Maximized" Title="HTML 5 Pivot Viewer Sample"
ResizeMode="CanResizeWithGrip">
<StackPanel Orientation="Vertical" Margin="5" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<StackPanel Orientation="Horizontal">
<Button x:Name="BackButton" Content="Back" Margin="5" Cursor="Hand" ToolTip="Press this button to navigate to the previous page" FontWeight="ExtraBold" MouseLeftButtonDown="BackButton_MouseLeftButtonDown"/>
<Button x:Name="NextButton" Content="Next" Margin="5" Cursor="Hand" ToolTip="Press this button to navigate to the next page." FontWeight="ExtraBold" MouseLeftButtonDown="NextButton_MouseLeftButtonDown"/>
<TextBox x:Name="UriFieldTextBox" TextWrapping="Wrap" Margin="10,5,5,5" VerticalContentAlignment="Stretch" ToolTip="Enter the Web Address that you wanted to navigate to and press the Go Button" HorizontalAlignment="Right" MinWidth="300"/>
<Button x:Name="GoButton" Content="Go" HorizontalAlignment="Right" Margin="5" FontWeight="ExtraBold" ToolTip="Press this button to navigate to the specified page." Cursor="Hand" MouseLeftButtonDown="GoButton_MouseLeftButtonDown"/>
</StackPanel>
<WebBrowser x:Name="MyWebBrowser" Margin="0" MinHeight="600" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Loaded="MyWebBrowser_Loaded" />
</StackPanel>
</Window>
public partial class MainWindow : Window
{
public MainWindow()
{
this.InitializeComponent();
// Insert code required on object creation below this point.
}
private void BackButton_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
// TODO: Add event handler implementation here.
MyWebBrowser.GoBack();
}
private void GoButton_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
// TODO: Add event handler implementation here.
MyWebBrowser.Navigating += new NavigatingCancelEventHandler(MyWebBrowser_Navigating);
MyWebBrowser.Navigated += new NavigatedEventHandler(MyWebBrowser_Navigated);
string address = UriFieldTextBox.Text.ToString().Trim();
MyWebBrowser.Navigate(new Uri(address,UriKind.RelativeOrAbsolute));
}
private void NextButton_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
// TODO: Add event handler implementation here.
MyWebBrowser.GoForward();
}
private void MyWebBrowser_Loaded(object sender, System.Windows.RoutedEventArgs e)
{
// TODO: Add event handler implementation here.
MyWebBrowser.Navigating += new NavigatingCancelEventHandler(MyWebBrowser_Navigating);
MyWebBrowser.Navigated+=new NavigatedEventHandler(MyWebBrowser_Navigated);
Uri uri = new Uri("C:\\Users\\Manthravadi\\Desktop\\lobsterpothtml5pivotviewer-0.6.8\\examples\\PASS Summit 2011.html",UriKind.Absolute);
MyWebBrowser.Source= uri;
}
void MyWebBrowser_Navigating(object sender,NavigatingCancelEventArgs args){
MessageBox.Show("Page is Loading ...\n\nPlease wait");
}
void MyWebBrowser_Navigated(object sender, NavigationEventArgs args){
MessageBox.Show("Page has been Loaded ...!");
}
此外,当我在UriFieldTextBox中输入“http://google.com”等地址(不带引号)并按下Go按钮时,没有页面正在加载,有人可以解释我哪里出错吗? / p>
~Harsha