Awesomium在WindowsBase.dll中引发ArgumentException

时间:2012-01-22 08:42:47

标签: c# wpf awesomium

我正在使用WPF创建一个应用程序,我有一个带有Awesomium WebControl的UserControl。

当我将这个UserControl的副本添加到我的主窗口时,我从WindowsBase.dll获得一个ArgumentException,说“宽度和高度必须为正”。

这是UserControl:

<UserControl x:Class="ForumPost.ForumPost"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         mc:Ignorable="d" MinWidth="505" MinHeight="250" xmlns:my="http://schemas.awesomium.com/winfx">
<Grid Name="postGrid" Margin="5">
    <Grid.RowDefinitions>
        <RowDefinition/>
        <RowDefinition/>
    </Grid.RowDefinitions>

    <Grid Background="#3166A1">
        <Grid.RowDefinitions>
            <RowDefinition MinHeight="150" />
        </Grid.RowDefinitions>

        <Grid.ColumnDefinitions>
            <ColumnDefinition MinWidth="150" />
            <ColumnDefinition MinWidth="100" />
            <ColumnDefinition MinWidth="125" />
            <ColumnDefinition MinWidth="125" />
        </Grid.ColumnDefinitions>

        <Grid Height="150">
            <Grid.RowDefinitions>
                <RowDefinition Height="25" />
                <RowDefinition Height="125" />
            </Grid.RowDefinitions>

            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition MinWidth="20"/>
                    <ColumnDefinition/>
                </Grid.ColumnDefinitions>

                <Image Margin="0 0 5 0" Name="specialUserFlag"/>

                <TextBlock TextAlignment="Center" FontWeight="Bold" FontSize="16" Foreground="White" Name="postUsername" Grid.Column="1"/>
            </Grid>

            <Image Grid.Row="1" MaxWidth="125" MaxHeight="125" Name="postAvatar" />
        </Grid>

        <TextBlock Grid.Column="2" TextAlignment="Center" FontWeight="Bold" FontSize="16" Foreground="White" VerticalAlignment="Center"  Name="postTimestamp" TextWrapping="Wrap" />

    </Grid>
    <my:WebControl Grid.Row="1" Name="webBrowser"/>
</Grid>    

这是我的主窗口,正如@LukeWoodward所要求的那样:

<Window
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero" x:Class="Saxaphone.MainWindow"
    Title="MainWindow" Height="850" Width="1600"
    Icon="main.ico">

<Grid x:Name="MainGrid">
    <Grid.RowDefinitions>
        <RowDefinition />
    </Grid.RowDefinitions>

    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="305" />
        <ColumnDefinition MinWidth="1017" />
    </Grid.ColumnDefinitions>

    <TreeView x:Name="ForumView" ScrollViewer.HorizontalScrollBarVisibility="Diforumbled" Style="{DynamicResource ForumViewStyle}" SelectedItemChanged="ForumView_SelectedItemChanged" />

    <Grid x:Name="forumGrid" Grid.Column="1">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="512" />
            <ColumnDefinition />
        </Grid.ColumnDefinitions>

        <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Hidden" Grid.Column="0" Height="{Binding ActualHeight, ElementName=forumGrid}">
                <StackPanel x:Name="forumThreads"></StackPanel>
        </ScrollViewer>

        <ScrollViewer VerticalScrollBarVisibility="Visible" HorizontalScrollBarVisibility="Auto" Grid.Column="1" Height="{Binding ActualHeight, ElementName=forumGrid}">
            <StackPanel x:Name="forumPosts"/>
        </ScrollViewer>
    </Grid>
</Grid>

2 个答案:

答案 0 :(得分:3)

我现在能够重现你正在获得的ArgumentException。我怀疑这是Awesomium中的一个错误。我建议您通过http://support.awesomium.com/联系Awesomium支持。

我发现以下XAML足以重现ArgumentException。在运行时不需要任何用户控件或添加控件:

<StackPanel>
    <as:WebControl xmlns:as="http://schemas.awesomium.com/winfx" />
</StackPanel>

我发现可以通过在Width上设置明确的HeightWebControl来解决此问题。似乎WebControl不喜欢进入StackPanel,除非它(WebControl {em} Width和{{1} } set。

答案 1 :(得分:0)

我们知道此问题,并将在 1.7 版本的最终版本中修复。