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

  • SEARCH
  • Home
  • 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 8012463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T19:20:22+00:00 2026-06-04T19:20:22+00:00

I have a simple program. it has a basic canvas with a button and

  • 0

I have a simple program. it has a basic canvas with a button and a FRAME.

  <Canvas Width="1200" Height="600" Name="frontPanel" Background="Blue">

         <Button Width="200" Height="90" Content="flipme" Click="flipme" VerticalAlignment="Top" HorizontalAlignment="Left" >
                <Button.RenderTransform>
                      <TransformGroup>
                           <TranslateTransform x:Name="BtnMove" X="500" Y="255" />
                      </TransformGroup>    
                </Button.RenderTransform>
          </Button>

          <Frame Name="wow" Width="1200" Height="600"></Frame>
  </Canvas>

What I want to accomplish is this, load another xaml page into the current page WITH its back end coding. All I’ve seen online is how to load another page and add the event handlers after its loaded.

my code that loads the page is as follows:

     string basePath = AppDomain.CurrentDomain.BaseDirectory;
     string commonPath = basePath.Remove(basePath.Length - @"\bin\Debug\".Length);
     wow.Source = (new Uri(commonPath + "\\Page2.xaml"));

Alright it works if there are no click methods attached to page2.xaml but when I attach a click event handler to a button in page2.xaml, the program tells me:

Failed to create a 'Click' from the text 'button1_Click_1'.' Line number '12' and line position '144'.

So my questions is there any way for me to load the page and the back end coding together without having to assign it later? cause I made the page2.xaml as a separate page with a separate back end coding. I need to load the page2.xaml in page1.xaml with its back end coding (click event handlers). I reiterate that I have searched the web and still have not find any solution to this problem.

  • 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-06-04T19:20:23+00:00Added an answer on June 4, 2026 at 7:20 pm

    XAML is just a way of constructing objects using a declarative style. It does not contain any “code”, it just constructs objects.

    The code in a page is placed in a codebehind file which is a standard .cs file. Note the “partial” keyword in the codebehind. This means it’s just part of a class, with the other part being constructed from the xaml. Both of these parts get compiled into your final class which knows nothing about the xaml used to create it.

    If you load a XAML file, that’s all you’re loading. A object that’s constructed from markup.

    If you want to encapsulate code behaviour, then you need to load an object, not a xaml file. The most suitable object that comes to mind is the UserControl, which is created from a xaml file and codebehind like you want.

    So if you want display objects with their own behaviour, make them UserControls.
    If you simply want different displays with the same behaviour, then load them as xaml files and hook up your events manually.

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

Sidebar

Related Questions

I have written a simple network program on java using sockets. Program has a
I have written a simple network program on java using sockets. Program has a
I currently have a program which has the following basic structure main function --
I have just noticed that my simple program has its data and stack segments
Say I have simple program that emulates a board game with a number of
I have Simple java program named MainController.java. Wehn I try to compile it from
I have this simple program #include <stdio.h> int main(void) { unsigned int a =
I have a simple program for iOS that contains numerous text fields. What I
I have a simple program that creates a thread, loops twenty times and then
I have a simple program to check if a port is open, but I

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.