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 1030895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T13:50:35+00:00 2026-05-16T13:50:35+00:00

I’m not even sure if this is even possible, but I’ve just started WPF

  • 0

I’m not even sure if this is even possible, but I’ve just started WPF development on a few new projects and tried to wrap up some common functionality by creating a mini-framework. Just things like exception handling and thread management.

What I would like to do is replace this line…

public partial class App : Application

with

public partial class App : MyFrameworkApplication

I’ve got the libraries set up and referenced, but I get an error regarding the ‘partially’ declared App class, presumably because it’s still referencing the old base class.

Any ideas? Thanks.

EDIT: @Jeff M: No, your solution didn’t work. I suspect because the MyFrameworkApplication is actually in a library and the z namespace declaration fails to recognise the library’s namespace. I’ve got it referenced in the App.xaml.cs, but the suspicious looking error is:

Error 3 Undefined CLR namespace. The 'clr-namespace' URI refers to a namespace 'MyLibraryNamespace' that is not included in the assembly.

I can circumvent the problem by creating a proxy class within the local namespace and having it derive from the library class…but it’s a bit smelly.

  • 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-16T13:50:36+00:00Added an answer on May 16, 2026 at 1:50 pm

    I suspect it’s because the the underlying XAML root is still an Application as opposed to MyFrameworkApplication. I’d guess the generated baml uses the root as it’s parent class. Try changing it to the appropriate names.

    e.g.,

    <z:MyFrameworkApplication x:Class="MyNamespace.App"
                 ...
                 xmlns:z="clr-namespace:MyNamespace">
        ...
    </z:MyFrameworkApplication>
    

    It seems my suspicions were correct.

    From the docs in Code-Behind and XAML in WPF:

    Code-behind, Event Handler, and Partial Class Requirements in WPF

    • The partial class must derive from the type that backs the root element. (emphasis mine)
    • Note that under the default behavior of the markup compile build actions, you can leave the derivation blank in the partial class
      definition on the code-behind side. The compiled result will assume
      the page root’s backing type to be the basis for the partial class,
      even if it not specified. However, relying on this behavior is not a
      best practice.
    • The event handlers you write in the code behind must be instance methods and cannot be static methods. These methods must be defined by
      the partial class within the CLR namespace identified by x:Class. You
      cannot qualify the name of an event handler to instruct a XAML
      processor to look for an event handler for event wiring in a different
      class scope.
    • The handler must match the delegate for the appropriate event in the backing type system.
    • For the Microsoft Visual Basic language specifically, you can use the language-specific Handles keyword to associate handlers with
      instances and events in the handler declaration, instead of attaching
      handlers with attributes in XAML. However, this technique does have
      some limitations because the Handles keyword cannot support all of the
      specific features of the WPF event system, such as certain routed
      event scenarios or attached events. For details, see Visual Basic and WPF Event Handling.

    The root application type in code-behind and in the xaml must agree.

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

Sidebar

Related Questions

No related questions found

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.