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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T06:44:02+00:00 2026-06-07T06:44:02+00:00

I am making my first WPF application, so this question may seem rather odd.

  • 0

I am making my first WPF application, so this question may seem rather odd. I have been reading about MVVM and so far it has made sense to me. What I don’t understand, though, is separating all the XAML.

What I mean is this: I assume you don’t place everything in the MainWindow.xaml and just collapse controls based upon what is going to be used. I would think you would want a container that would contain xaml of other files. Is this correct?

How do you go about separating the XAML out so that it isn’t just a mash of everything in one file?

  • 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-07T06:44:03+00:00Added an answer on June 7, 2026 at 6:44 am

    How do you go about separating the XAML out so that it isn’t just a mash of everything in one file?

    There are many ways, including creating a seperate UserControl, CustomControl, Page or Window

    For example, if you wanted to pull some XAML out of your MainWindow.xaml, you could create a UserControl (right-click project, Add, New Item…, User Control (WPF)) called MyUserControl.xaml like this:

    <UserControl x:Class="WpfApplication1.MyUserControl"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
        <Grid>
            <TextBlock>This is from a different XAML file.</TextBlock>
        </Grid>
    </UserControl>
    

    and then use this control in your MainWindow.xaml like this:

    <Window x:Class="WpfApplication1.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
            xmlns:myControls="clr-namespace:WpfApplication1">
        <Grid>
            <myControls:MyUserControl/>
        </Grid>
    </Window>
    

    Note that you need to add a reference to the namespace of your UserControl

    xmlns:myControls="clr-namespace:WpfApplication1"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my application (WPF) i have this window: public partial class Window1 : Window
I'm making my first foray into WPF - I have a simple form with
Making my first steps in RIA Services (VS2010Beta2) and i encountered this problem: created
I'm making my first iphone application and it's a wine chart application. It's with
I am making my first android application, and it requires switching between activities very
I'm making my first steps with unit testing and am unsure about two paradigms
I apologize for making my first question not the hard-hitting code-related question I was
I am making my first web application with ASP.NET and I am having a
I have been stuck on this all weekend and failed miserably! Please help me
I'm making my first Windows Phone App As per this tutorial [ http://msdn.microsoft.com/en-us/library/gg680266(v=pandp.11).aspx ],

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.