How to use 'Back' & 'Forward' navigation button events in WPF WebBrowser?

后端 未结 3 1037
小鲜肉
小鲜肉 2021-01-02 10:51

The WebBrowser control in WPF is inherited from theUIElement, but we cannot register event handlers in UIElement events. Why is it? At

3条回答
  •  长情又很酷
    2021-01-02 11:11

    The WebBrowser controll is really just thin wrapper around the Trident COM object. It's not 'pure WPF' like other built-in controls... so lots of normal things don't work with it. To answer your question, the closest you can get is hooking into the Navigating event. This won't tell you whether the user is trying to go forwards or back or elsewhere but it will give you the URL and the opportunity to set e.Cancel = true to stop the navigation (usually followed by calling Navigate(url) to take the user somewhere else).

提交回复
热议问题