2017-04-10 08:15:55 +08:00
|
|
|
|
using CefSharp.Wpf;
|
|
|
|
|
using System.Windows;
|
2017-04-10 08:34:08 +08:00
|
|
|
|
using System;
|
2020-08-26 14:27:10 +08:00
|
|
|
|
using Microsoft.Xaml.Behaviors;
|
2017-04-10 08:15:55 +08:00
|
|
|
|
|
|
|
|
|
namespace CefSharp.MinimalExample.Wpf.Behaviours
|
|
|
|
|
{
|
|
|
|
|
public class HoverLinkBehaviour : Behavior<ChromiumWebBrowser>
|
|
|
|
|
{
|
2017-04-10 08:34:08 +08:00
|
|
|
|
// Using a DependencyProperty as the backing store for HoverLink. This enables animation, styling, binding, etc...
|
2017-04-10 08:15:55 +08:00
|
|
|
|
public static readonly DependencyProperty HoverLinkProperty = DependencyProperty.Register("HoverLink", typeof(string), typeof(HoverLinkBehaviour), new PropertyMetadata(string.Empty));
|
|
|
|
|
|
|
|
|
|
public string HoverLink
|
|
|
|
|
{
|
|
|
|
|
get { return (string)GetValue(HoverLinkProperty); }
|
|
|
|
|
set { SetValue(HoverLinkProperty, value); }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnAttached()
|
|
|
|
|
{
|
|
|
|
|
AssociatedObject.StatusMessage += OnStatusMessageChanged;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnDetaching()
|
|
|
|
|
{
|
|
|
|
|
AssociatedObject.StatusMessage -= OnStatusMessageChanged;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnStatusMessageChanged(object sender, StatusMessageEventArgs e)
|
|
|
|
|
{
|
2017-04-10 08:34:08 +08:00
|
|
|
|
var chromiumWebBrowser = sender as ChromiumWebBrowser;
|
|
|
|
|
chromiumWebBrowser.Dispatcher.BeginInvoke((Action)(() => HoverLink = e.Value));
|
2017-04-10 08:15:55 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|