Click here to Skip to main content
15,891,943 members

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
HTML
<usercontrol x:class="ManyWpfControlLibrary.UserControl1" xmlns:x="#unknown">
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="150" d:DesignWidth="300">
    <grid removed="#FFFA8383">

    </grid>
</usercontrol>


with code-behind
C#
namespace ManyWpfControlLibrary
{
    /// <summary>
    /// Interaction logic for UserControl1.xaml
    /// </summary>
    public partial class UserControl1 : UserControl
    {
        public UserControl1()
        {
            InitializeComponent();
        }
    }
}


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

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



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.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900