想不到用WPF做浏览器居然这么简单,就完成了浏览器的功能 只要用Fream,并指定个Uri给它当Source,就可以达成了 using System; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; using System.Windows.Documents; using System.Windows.Controls.Primitives; namespace Cloud.NavigateTheWeb { public class NavigateTheWeb : Window { Frame frm; [STAThread] public static void Main() { Application app = new Application(); app.Run(new NavigateTheWeb()); } public NavigateTheWeb() { this.Title = "Cloud Orz"; frm = new Frame(); Content = frm; this.Loaded += new RoutedEventHandler(NavigateTheWeb_Loaded); } void NavigateTheWeb_Loaded(object sender, RoutedEventArgs e) { UriDialog dlg = new UriDialog(); dlg.Owner = this; dlg.Text = "http://"; dlg.ShowDialog(); try { frm.Source = new Uri(dlg.Text); } catch (Exception ex) { MessageBox.Show(ex.Message); } } } class UriDialog : Window { TextBox txtbox; public UriDialog() { Title = "Enter a URI"; ShowInTaskbar = false; SizeToContent = SizeToContent.WidthAndHeight; WindowStyle = WindowStyle.ToolWindow; WindowStartupLocation = WindowStartupLocation.CenterOwner; txtbox = new TextBox(); txtbox.Margin = new Thickness(48); Content = txtbox; txtbox.Focus(); } public string Text { set { txtbox.Text = value; txtbox.SelectionStart = txtbox.Text.Length; } get { return txtbox.Text; } } protected override void OnKeyDown(KeyEventArgs e) { if (e.Key == Key.Enter) Close(); } } }