所有:Awesomium WPF的WebControl设置.Source属性不起作用
希望有人在使用WPF作为Awesomium我现在做的事情。
我有一个包含WebControl的WPF控件,我要动态地设置源
然而,似乎设置.Source不会在所有的工作。它将始终保留在源代码第一次设置的页面中。
版我现在用的就是Awesomium 1.7器Rc3
基本上我更新Awesomium提供1.7器Rc3 SDK,项目
XAML中部分的示例代码:
<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>
代码背后是像
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++;
}
当我点击按钮,我想webcontro我应该在雅虎和谷歌之间切换, ,但是当我点击时没有任何反应。
。源应该是什么触发导航。你可以发布一些代码,以便我们可以看到你的使用情况? – HotN
@HotN我更新了代码,你能帮忙吗?谢谢。目前我在WPF托管的Win Form中使用WebControl,但我认为这不是一个好主意,因为我宁愿使用本机WPF。 – BloodroseWu