Click here to Skip to main content
13,086,248 members (85,516 online)

How to insert wpf UserConrol projects into a MainWindow project at runtime (Finally was solved:-)

hzawary asked:

Open original thread
Hi sir

Ok, I want loading any UserContols as DLL on a MainWindow project as host by selecting them in runtime.
I tried this article SelfContainedAssembly[^] and I converted it to a WPF project that you can see MyProject[^], also test it with StackPanel and etc succesfully, but I want develope a WPF UserControl project like this
<usercontrol x:class="ManyWpfControlLibrary.UserControl1" xmlns:x="#unknown">
             d:DesignHeight="150" d:DesignWidth="300">
    <grid removed="#FFFA8383">

with code-behind
namespace ManyWpfControlLibrary
    /// <summary>
    /// Interaction logic for UserControl1.xaml
    /// </summary>
    public partial class UserControl1 : UserControl
        public UserControl1()

This UserControl compiled to a DLL file, finally it would insert into my MainWindow project at runtime, but I couldn't to do this.

In fact, we haven't aware about the DLL (UserControl compiled), it created and developed offline by another persons and there is on a different assembly, only we load and insert it on the main project at runtime!

Help me about this method or another idea. If the issue is ambiguous and you got the idea, please you edit this post to more understanding.

Thanks in advance.
Tags: C#, .NET, XAML, WPF, UI


When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).

Advertise | Privacy |
Web04 | 2.8.170813.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2017
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