Reputation: 861
ALl:
Hopefully someone is using Awesomium in WPF as I am doing now.
I have a WPF control containing a WebControl which I want to dynamically set the source
However, it seems that setting .Source does not work at all. It will always stay in the page that the source is set the very first time.
Version I am using now is Awesomium 1.7 Rc3
Basically I updated the sample code provided in Awesomium 1.7 Rc3 sdk, project
Xaml Part:
<Grid SnapsToDevicePixels="True">
<Grid.RowDefinitions>
<RowDefinition Height="auto"/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Button x:Name="btn" Click="Button_Click" Content="Navigate" Width="500" Height="100"/>
<awe:WebControl Grid.Row="1"
Name="webControl"
Source="http://stackoverflow.com"
ShowCreatedWebView="OnShowNewView" Width="900" Height="1000"/>
</Grid>
Code Behind is like
public MainWindow()
{
WebCore.Initialize( new WebConfig() { LogLevel = LogLevel.Verbose } );
InitializeComponent();
}
protected override void OnClosed( EventArgs e )
{
base.OnClosed( e );
webControl.Dispose();
WebCore.Shutdown();
}
private void OnShowNewView( object sender, ShowCreatedWebViewEventArgs e )
{
if ( !webControl.IsLive )
return;
e.Cancel = true;
webControl.Source = e.TargetURL;
}
static int i = 0;
private void Button_Click(object sender, RoutedEventArgs e)
{
if (i % 2 == 0)
this.webControl.Source = new Uri("http://yahoo.com.sg");
else
this.webControl.Source = new Uri("http://google.com.sg");
i++;
}
When I click the button, I suppose that webcontrol should toggle between yahoo and google, but nothing happens when I click.
Upvotes: 1
Views: 5571
Reputation: 4386
You're code is correct and is using the API as the documentation instructs. However, this turns out to be a bug with Awesomium 1.7RC3. See this post in the support forums.
You can still use WebControl.LoadURL() for this release.
Upvotes: 3