Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Error in simple application
Message
From
09/12/2008 14:57:51
 
 
To
All
General information
Forum:
ASP.NET
Category:
Windows Presentation Foundation (WPF)
Title:
Error in simple application
Miscellaneous
Thread ID:
01366277
Message ID:
01366277
Views:
63
I created my first simple winforms host xaml application containing one simple page.

Trying to run it causes error

System.Windows.Markup.XamlParseException was unhandled
Message: Cannot create instance of 'Page1' defined in assembly 'WPFHost,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Exception has been
thrown by the target of an invocation. Error in markup file 'Page1.xaml'
Line 1 Position 7.

There is no any other inforamtion available about this error.
How to fix?

Andrus.

Page1.xaml:
<Page x:Class="WPFHost.Page1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Page1">
    <Grid>
        <StackPanel Margin="0,0,0,0" Name="stackPanel"
           HorizontalAlignment="Left" VerticalAlignment="Top" />
    </Grid>
</Page>




page1.xaml.cs:


using System.Windows.Controls;
using System.Windows.Forms.Integration;
using MyApp.UI;

namespace WPFHost
{
    /// <summary>
    /// Interaction logic for Page1.xaml
    /// </summary>
    public partial class Page1 : Page
    {
        private readonly MainForm mainForm = new MainForm();

        public Page1()
        {
            InitializeComponent();

            //Create a Windows Forms Host to host a form
            WindowsFormsHost windowsFormsHost = new WindowsFormsHost();

            stackPanel.Width = mainForm.Width;
            stackPanel.Height = mainForm.Height;
            windowsFormsHost.Width = mainForm.Width;
            windowsFormsHost.Height = mainForm.Height;

            mainForm.TopLevel = false;

            windowsFormsHost.Child = mainForm;

            stackPanel.Children.Add(windowsFormsHost);
        }
    }
}
Andrus
Next
Reply
Map
View

Click here to load this message in the networking platform