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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:50:42+00:00 2026-06-10T08:50:42+00:00

Bear with me because I’m new to WPF/XAML. I’m trying to write a MainWindow.xaml

  • 0

Bear with me because I’m new to WPF/XAML. I’m trying to write a MainWindow.xaml / App.xaml pair that properly isolates stylization and data binding, as close to a model-view-controller as possible. So far:

  • I have a styles.xaml that contains all of the formatting (fonts, margins, etc.). It’s referred to from app.xaml’s Application.Resources so that it can apply to all WPF forms in the project.
  • Model data collections exist as member variables of App, and App exposes them via GetX() acccessor functions.
  • mainwindow.xaml contains the view structure, as well as binding information. This is done like so:

    ObjectDataProvider x:Key=”AppX” MethodName=”GetX”
    ObjectInstance=”{x:Static local:App.Current}”

The fact that mainwindow.xaml contains binding information is bad, since that should be the role of the controller (app). Unfortunately, I’ve found out that one of the restrictions of the WPF designer is that you can’t (for instance) have two unkeyed Resources references (one for view styles, one for data binding styles). Similarly, app.xaml can’t contain both the styles.xaml reference and a set of data binding styles in its Resources section.

I could theoretically manually instantiate the main window from the app’s startup handler, and then do the binding in code, but that would violate the spirit of WPF in two ways – the app shouldn’t need to make the window, as that’s done in the background; and binding is better done in XAML than in code when possible. If there were a way for the app to be notified that the main window has been created so that it can then do binding, that wouldn’t be bad, but I haven’t seen any (short of the main window calling the app after load, but that shouldn’t be the responsibility of the view).

So I’m kind of out on a limb. I don’t know of a way to properly adhere to MVC while still doing things “the WPF way” – it seems that the default is for the VS designer to create a monolithic window XAML that has a mishmash of view, view stylization, and controller. Any descriptions on how to do this better or links to good websites on the topic will be appreciated.

  • 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-10T08:50:43+00:00Added an answer on June 10, 2026 at 8:50 am

    MVVM is essentially MVC. In MVVM there is an extra seperation of the View into a view and view model where the view now is merely the controls of the UI and the view model holds the data and logic of the view. Additionaly, in MVVM, the relationship between the View and View Model, in isolation, can also be seen as the MVC pattern where M = ViewModel, V = View, C = DataBinding.

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

Sidebar

Related Questions

Please bear in mind that I'm totally new to Rails when answering this.My question
I'm new to objective-C so, bear with me. I started with the Universal App
I'm new to this site but bear with me. I'm trying to GROUP BY
Very new to C so please bear with me! I'm trying to read 3
Bear with me, as I'm quite new to using regular expressions. I have regexp
Bear with me, as this is my first Android app. :) Essentially, I would
Please bear with me as I am new to dojo, javascript, and web programming
please bear with my newbie questions.. I was trying to convert PDF to PNG
Please bear with me because my query is difficult to explain. Is it possible
This is a convoluted example so bear with me: I have a script that

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.