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. C#
  4. How to show UserControl(WPF) in a form project with not use ElementHost?

How to show UserControl(WPF) in a form project with not use ElementHost?

Scheduled Pinned Locked Moved C#
csharpwpftutorialquestion
5 Posts 3 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.
  • U Offline
    U Offline
    User 13049321
    wrote on last edited by
    #1

    I know how to show a UserControl(WPF) by ElementHost in a form. like this:

    private ElementHost m_elementHost;
    private UserControl1 m_uc;

    private void button1_Click(object sender, EventArgs e)
    {
    m_elementHost.Child = m_uc;
    }

    but I want to do show UserControl1 not use ElementHost, like this:

    private void button1_Click(object sender, EventArgs e)
    {
    UserControl1 uc = new UserControl1();

         uc.Show();
    

    }

    D L 2 Replies Last reply
    0
    • U User 13049321

      I know how to show a UserControl(WPF) by ElementHost in a form. like this:

      private ElementHost m_elementHost;
      private UserControl1 m_uc;

      private void button1_Click(object sender, EventArgs e)
      {
      m_elementHost.Child = m_uc;
      }

      but I want to do show UserControl1 not use ElementHost, like this:

      private void button1_Click(object sender, EventArgs e)
      {
      UserControl1 uc = new UserControl1();

           uc.Show();
      

      }

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      If you're asking how to show a WPF UserControl in a Windows Forms app without using ElementHost, you can't. ElementHost is required.

      Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
      Dave Kreskowiak

      U 1 Reply Last reply
      0
      • U User 13049321

        I know how to show a UserControl(WPF) by ElementHost in a form. like this:

        private ElementHost m_elementHost;
        private UserControl1 m_uc;

        private void button1_Click(object sender, EventArgs e)
        {
        m_elementHost.Child = m_uc;
        }

        but I want to do show UserControl1 not use ElementHost, like this:

        private void button1_Click(object sender, EventArgs e)
        {
        UserControl1 uc = new UserControl1();

             uc.Show();
        

        }

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Stick the user control in a WPF Window; then you can "show" it. Hide the window's "chrome" if that's a problem. Same result.

        The Master said, 'Am I indeed possessed of knowledge? I am not knowing. But if a mean person, who appears quite empty-like, ask anything of me, I set it forth from one end to the other, and exhaust it.' ― Confucian Analects

        U 1 Reply Last reply
        0
        • D Dave Kreskowiak

          If you're asking how to show a WPF UserControl in a Windows Forms app without using ElementHost, you can't. ElementHost is required.

          Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
          Dave Kreskowiak

          U Offline
          U Offline
          User 13049321
          wrote on last edited by
          #4

          thanks

          1 Reply Last reply
          0
          • L Lost User

            Stick the user control in a WPF Window; then you can "show" it. Hide the window's "chrome" if that's a problem. Same result.

            The Master said, 'Am I indeed possessed of knowledge? I am not knowing. But if a mean person, who appears quite empty-like, ask anything of me, I set it forth from one end to the other, and exhaust it.' ― Confucian Analects

            U Offline
            U Offline
            User 13049321
            wrote on last edited by
            #5

            Thank you.

            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