Awesomium .NET。 Wpf。 TitleChanged 事件

Awesomium .NET. Wpf. TitleChanged event

我有一个非常基本的应用程序,它在 WPF 应用程序中显示网站内容。一切正常,除了 TitleChangedEvent。这是代码示例 (XAML):

<Window xmlns:awe="http://schemas.awesomium.com/winfx"  x:Class="ShopChat.Desktop.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:webControls="clr-namespace:System.Web.UI.WebControls;assembly=System.Web"
    Title="{Binding ElementName=WebControl, Path=Title}" MinHeight="480" MinWidth="640">
<Grid>
  <awe:WebControl x:Name="WebControl"/>
</Grid>

这是主要的 window code-behind:

public MainWindow()
    {
        InitializeComponent();
        string url = @"http://shopchat.dev";
        try
        {
            url = ConfigurationManager.AppSettings.Get("Url");
        }
        catch (Exception)
        {
        }

        WebControl.Source = new Uri(url);
        WebControl.TitleChanged += WebControl_OnTitleChanged;
        this.WindowTitle = "Quickchat";
    }

    public string WindowTitle
    {
        get { return (string)GetValue(WindowTitleProperty); }
        set { SetValue(WindowTitleProperty, value); }
    }

    // Using a DependencyProperty as the backing store for WindowTitle.  This enables animation, styling, binding, etc...
    public static readonly DependencyProperty WindowTitleProperty =
        DependencyProperty.Register("WindowTitle", typeof(string), typeof(MainWindow), new PropertyMetadata(null));


    private void WebControl_OnTitleChanged(object sender, TitleChangedEventArgs e)
    {
        this.WindowTitle = e.Title;
    }

我还尝试使用绑定 ElementName=WebControl 直接绑定到 window 标题。那对我也没有帮助。

JavaScript 客户端代码非常简单:它在计时器 (setInterval) 上更改文档标题。

我做错了什么?

试试这个代码

public MainWindow()
{
     InitializeComponent();

      DataContext = this;

     MyTitle = "Title";
 }

那么你只需要在 XAML

  Title="{Binding MyTitle}"

那么你不需要依赖项属性。

那么我想用这个 INotifyPropertyChanged 和一个标准的 属性。

问题已解决。 TitleChanged 事件似乎还不够。我合并了全局 js 对象的用法以获得必要的行为。