Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6752429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:02:37+00:00 2026-05-26T13:02:37+00:00

I have an application with two Canvas controls. When the application starts, it loads

  • 0

I have an application with two Canvas controls. When the application starts, it loads from a DLL a UserControl which is basically Canvas with a bunch of XAML code.

I want to be able to display this control in the two Canvases, however, when I use the ContentPresenter and bind it in both Canvases to the control loaded from the DLL it shows only on one canvas and on the other it doesn’t. I guess it’s something that has to do with the fact that I’m actually using the same resource in two different Canvases, but since I wanted to avoid using too much memory (the control loaded from the DLL is pretty heavy) I didn’t want to create two copies of the same control.

Does anyone have a better approach / solution for this situation?

This is the XAML for showing the loaded control in one of the two canvases (the other canvas uses similar code)

<Canvas Width="{Binding MapModel.MapControl.Bounds.Width}" Height="{Binding MapModel.MapControl.Bounds.Height}">
    <Canvas.Background>
         <VisualBrush>
             <VisualBrush.Visual>
                  <ContentPresenter Content="{Binding MapModel.MapControl}" />
             </VisualBrush.Visual>
         </VisualBrush>
    </Canvas.Background>
 </Canvas>

And loading from the DLL is performed by:

  // Load the map library assembly (Using reflection)
  Assembly asm = Assembly.LoadFile(m_fileName);
  Type[] tlist = asm.GetTypes();

  // Find the class that represents the airport XAML drawing in the assembly, if it finds the airport class then 
  // set the value to be an instance of that class.
  foreach (Type t in tlist)
  {
    if (t.Name == "Map")
    {
      MapControl = Activator.CreateInstance(t) as UserControl;
      break;
    }
  }

Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:02:37+00:00Added an answer on May 26, 2026 at 1:02 pm

    Set attribute x:Shared="False" to your resource.
    It is 'true' so wpf creates one resource (for optimize performance) by default. When you set it 'false' wpf creates new instance per request.
    There are sample of this

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have added canvas in the xaml file. From code iam creating two rectangles
I have a web application and two class files, First class is MyClass.class which
I have two windows application, one is a windows service which create EventWaitHandle and
I have created a wpf application ,there are two canvas i would like to
I have an application where two column could be populated from a number of
I have two application that need to talk to each other. App1 needs to
I have an application that has two threads. The first one (the main thread)
I have a web application containing two web services, let's say PublicHello.asmx and RestrictedHello.asmx
I have application in VB.net that have two different form (Form1 and Form2). Now
Is tight looping in a program bad? I have an application that has two

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.