J'ai une application très basique, qui montre le contenu du site Web dans l'application WPF. Tout fonctionne bien, sauf TitleChangedEvent. Voici l'exemple de code (XAML):Awesomium .NET. Wpf. Événement TitleChanged
<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>
Et voici le code-behind fenêtre principale:
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;
}
J'ai aussi essayé de se lier à titre de la fenêtre directement à l'aide Reliure ElementName=WebControl
. Cela ne m'a pas aidé non plus.
Le code client JavaScript est très simple: il change le titre du document sur timer (setInterval).
Qu'est-ce que je fais mal?
Pour tous ceux qui pensent que le problème principal est la liaison de données, notez que le problème principal est que "TitleChangedEvent" est supposé être déclenché quand document.title dans le client javascript change ne fonctionne pas comme prévu –