【问题标题】:Awesomium WPF WebControl Setting .Source property does not workAwesomium WPF WebControl Setting .Source 属性不起作用
【发布时间】:2012-11-23 07:40:41
【问题描述】:

所有:

希望有人像我现在一样在 WPF 中使用 Awesomium。

我有一个 WPF 控件,其中包含我想动态设置源的 WebControl

但是,设置 .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++;
    }

当我点击按钮时,我想 webcontrol 应该在 yahoo 和 google 之间切换, 但是当我点击时没有任何反应。

【问题讨论】:

  • .Source 应该是触发导航的原因。您能否发布一些代码,以便我们查看您的使用情况?
  • @HotN 我更新了代码,你能帮忙吗?谢谢。目前我在 WPF 中托管的 Win Form 中使用 WebControl,但我认为这不是一个好主意,因为我宁愿使用原生 WPF。

标签: wpf web-controls awesomium


【解决方案1】:

您的代码是正确的,并且按照文档说明使用 API。然而,这被证明是 Awesomium 1.7RC3 的一个错误。请在支持论坛中查看 this post

您仍然可以在此版本中使用 WebControl.LoadURL()

【讨论】:

    猜你喜欢
    • 2013-05-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多