Skip to content

Commit 8ba6b6b

Browse files
committed
Add NavStateChanged EventHandler to WPF control
Add NavStateChanged to IWebBrowser Update xml comment Add stub to Offscreen ChromiumWebBrowser
1 parent 907cca8 commit 8ba6b6b

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

CefSharp.OffScreen/ChromiumWebBrowser.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ public Task<Bitmap> ScreenshotAsync()
184184
public event EventHandler<ConsoleMessageEventArgs> ConsoleMessage;
185185
public event EventHandler BrowserInitialized;
186186
public event EventHandler<StatusMessageEventArgs> StatusMessage;
187+
public event EventHandler<NavStateChangedEventArgs> NavStateChanged;
187188

188189
public void ShowDevTools()
189190
{

CefSharp.Wpf/ChromiumWebBrowser.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ public class ChromiumWebBrowser : ContentControl, IRenderWebBrowser, IWpfWebBrow
5757
public event EventHandler<FrameLoadStartEventArgs> FrameLoadStart;
5858
public event EventHandler<FrameLoadEndEventArgs> FrameLoadEnd;
5959
public event EventHandler<LoadErrorEventArgs> LoadError;
60+
public event EventHandler<NavStateChangedEventArgs> NavStateChanged;
6061

6162
public ICommand BackCommand { get; private set; }
6263
public ICommand ForwardCommand { get; private set; }
@@ -677,6 +678,12 @@ void IWebBrowserInternal.SetNavState(bool canGoBack, bool canGoForward, bool can
677678

678679
RaiseCommandsCanExecuteChanged();
679680
});
681+
682+
var handler = NavStateChanged;
683+
if (handler != null)
684+
{
685+
handler(this, new NavStateChangedEventArgs(canGoBack, canGoForward, canReload));
686+
}
680687
}
681688

682689
private void RaiseCommandsCanExecuteChanged()

CefSharp/IWebBrowser.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ public interface IWebBrowser : IDisposable
3939
/// </summary>
4040
event EventHandler<LoadErrorEventArgs> LoadError;
4141

42+
/// <summary>
43+
/// Event handler that will get called when the Navigation state has changed (Maps to OnLoadingStateChange in Cef).
44+
/// This event will be fired twice. Once when loading is initiated either programmatically or
45+
/// by user action, and once when loading is terminated due to completion, cancellation of failure.
46+
/// </summary>
47+
event EventHandler<NavStateChangedEventArgs> NavStateChanged;
48+
4249
/// <summary>
4350
/// Loads the specified URL.
4451
/// </summary>

CefSharp/IWinFormsWebBrowser.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ namespace CefSharp
1010
// so the dependency would go the wrong way... Has to be here for the time being.
1111
public interface IWinFormsWebBrowser : IWebBrowser
1212
{
13-
event EventHandler<NavStateChangedEventArgs> NavStateChanged;
1413
event EventHandler<TitleChangedEventArgs> TitleChanged;
1514
event EventHandler<AddressChangedEventArgs> AddressChanged;
1615
void Undo();

0 commit comments

Comments
 (0)