Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
Hi everyone, I'm new here and have used this site very frequently for help. It is a great resource so far, and I'm happy to say it has helped a lot. I'm primarily an engineer/embedded guy, but I'm needed to work on some GUI's and communication protocols. I've only been doing c# or any OOP language for about a month so bear with me.
 
I've got my base communication and background coded in winforms and I need to start using wpf for animations and the GUI. Unfortunately, my timer graphical system in winforms lags on slower computers and is unacceptable.
 
I've found very few topics on opening a wpf window from winforms. I've attached my project which has an error in referencing the namespace. I've used the same references in both the wpf and winforms projects that are in my solution. The code is as follows.
 

winforms code...
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Forms;
using System.Windows.Forms.Integration;
 

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
 

        }
 
        private void button1_Click(object sender, EventArgs e)
        {
            var wpfWindow = new WpfApplication1.MainWindow();
            //var wpfWindow = new WpfApplication1.MainWindow();
            wpfWindow.Show();
        }
    }
}
 
The wpf code...
 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Windows.Forms;
using System.Windows.Forms.Integration;
 

namespace WpfApplication1
{
 
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
    }
}
 

 
The error is here...
 
Error 1 The type or namespace name 'WpfApplication1' could not be found (are you missing a using directive or an assembly reference?) C:\Users\alna072683\Desktop\wpftowin\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs 34 33 WindowsFormsApplication1
 

 

 
If anyone could let me know what I'm doing wrong that would be great!
Posted 25-Sep-12 3:26am
Edited 25-Sep-12 5:27am
v2

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

assuming you are using microsoft visual c# go to: project -> add reference -> browse and add the wpf file. this should solve your error
  Permalink  
Comments
bassplayer142 at 25-Sep-12 11:27am
   
Thank you sir! It worked right away.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 220
1 OriginalGriff 145
2 _Amy 115
3 manoj kumar choubey 110
4 Sergey Alexandrovich Kryukov 105
0 OriginalGriff 7,320
1 Sergey Alexandrovich Kryukov 6,043
2 Maciej Los 3,749
3 Peter Leow 3,408
4 DamithSL 2,555


Advertise | Privacy | Mobile
Web02 | 2.8.140721.1 | Last Updated 25 Sep 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100