Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Can not Convert System.Windows.Controls to System.Windows.Forms.Controls [modified]

Can not Convert System.Windows.Controls to System.Windows.Forms.Controls [modified]

Scheduled Pinned Locked Moved WPF
wpfhelpcsharpcssdotnet
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bruze
    wrote on last edited by
    #1

    Can any one Help I have created one Panel Control(System.Windows.Forms) using wpf window application and create one user control using Windows Control Library. I want to add the usercontrol in Panel I have tried the following code xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:wfi="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration" xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms" Title="Sivam" Height="300" Width="300" Loaded="Form_Load"> grid> windowsformshost margin="7.37,6.72333333333333,48,22"> wf:panel height="50" x:name="panel1" text="Prompt" xmlns:wf="#unknown" /> /windowsformshost> /grid> /window>; private void Form_Load(object Sender, EventArgs e) { UserControl1 uc1 = new UserControl1(); **panel1.Controls.Add(uc1);** //System.Windows.Forms.Integration.ElementHost host = new System.Windows.Forms.Integration.ElementHost(); //UserControl1 uc1 = new UserControl1(); //host.Controls.Add(uc1); //panel1.Controls.Add(host); } But I got the Error Convert System.Windows.Controls to System.Windows.Forms.Controls Thanks, Siva

    modified on Thursday, September 11, 2008 9:52 AM

    C 1 Reply Last reply
    0
    • B bruze

      Can any one Help I have created one Panel Control(System.Windows.Forms) using wpf window application and create one user control using Windows Control Library. I want to add the usercontrol in Panel I have tried the following code xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:wfi="clr-namespace:System.Windows.Forms.Integration;assembly=WindowsFormsIntegration" xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms" Title="Sivam" Height="300" Width="300" Loaded="Form_Load"> grid> windowsformshost margin="7.37,6.72333333333333,48,22"> wf:panel height="50" x:name="panel1" text="Prompt" xmlns:wf="#unknown" /> /windowsformshost> /grid> /window>; private void Form_Load(object Sender, EventArgs e) { UserControl1 uc1 = new UserControl1(); **panel1.Controls.Add(uc1);** //System.Windows.Forms.Integration.ElementHost host = new System.Windows.Forms.Integration.ElementHost(); //UserControl1 uc1 = new UserControl1(); //host.Controls.Add(uc1); //panel1.Controls.Add(host); } But I got the Error Convert System.Windows.Controls to System.Windows.Forms.Controls Thanks, Siva

      modified on Thursday, September 11, 2008 9:52 AM

      C Offline
      C Offline
      chaiguy1337
      wrote on last edited by
      #2

      It looks to me like you either have a namespace issue, or you're trying to add the wrong type somewhere. For example, if UserControl1 is a WPF control (which it appears to be), you can't add that to a windows forms panel. Use the Canvas class instead. The windows forms host is for hosting windows forms controls inside a WPF window.

      “Time and space can be a bitch.” –Gushie, Quantum Leap {o,o}.oO( Looking for a great RSS reader? Try FeedBeast! ) |)””’)            Built with home-grown CodeProject components! -”-”-

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups