Question

I am making an application with WPF and I have a UserControl with a Awesomium WebControl.

The moment I add a copy of this UserControl to my main window, I get an ArgumentException from WindowsBase.dll saying that "Width and Height must be positive".

Here is that 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>    

And here is my main window, as @LukeWoodward requested:

<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>

Was it helpful?

Solution

I've now been able to reproduce the ArgumentException you're getting. I suspect that this is a bug in Awesomium. I would recommend that you contact Awesomium Support at http://support.awesomium.com/.

I found that the following XAML is sufficient to reproduce the ArgumentException. There was no need for any user-controls nor adding controls at runtime:

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

I found that it was possible to work around this issue by setting an explicit Width and Height on the WebControl. It seems that a WebControl doesn't like being inside a StackPanel unless it (the WebControl) has both Width and Height set.

OTHER TIPS

We are aware of this issue and it will be fixed in the final release of version 1.7.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top