我正在使用 CefSharp 进行培训,但我无法找到如何检查网站是否已完全加载的事实。当您单击该按钮时,该站点将打开,并且在它完全加载后,我想显示一条消息。事实证明,消息出现了,网站还没有打开。请帮我解决这个问题,我在网上搜索但没有找到明确的解决方案。
这就是我现在所拥有的。
<Window x:Class="CefSharpApp.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:CefSharpApp"
xmlns:cef="clr-namespace:CefSharp.Wpf;assembly=CefSharp.Wpf"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="900">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300"></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Button Click="Button_Click" Grid.Column="0" Content="google" Height="30" VerticalAlignment="Top" Margin="5, 5 ,5 ,0"/>
<cef:ChromiumWebBrowser Grid.Column="1" x:Name="Browser_Test" Address="" />
</Grid>
</Window>
using CefSharp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace CefSharpApp
{
/// <summary>
/// Логика взаимодействия для MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
Browser_Test.Address = "https://google.com";
MessageBox.Show("Сайт полностью загружен");
}
}
}
帮助编写正确的代码。这样该消息仅在站点完全加载并显示后才会出现。
https://stackoverflow.com/a/41985473/5045688
Click
你能为按钮创建一个事件处理程序吗?这是同样的事情。