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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:41:58+00:00 2026-05-22T17:41:58+00:00

Trying to get my head around MVVM, and getting a simple window to render

  • 0

Trying to get my head around MVVM, and getting a simple window to render its viewmodel as a view via data templating.

in App.xaml:

<Application.Resources>
   <DataTemplate DataType="{x:Type vm:TestViewModel}">
      <vw:TestView />
   </DataTemplate>
</Application.Resources>

View definition:

<UserControl x:Class="MyNamespace.TestView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <TextBlock>TESTING</TextBlock>
    </Grid>
</UserControl>

In MainWindowViewModel:

private void onOpenTestView(object sender)
{
   Window w = new Window();
   w.Content = new TestViewModel();
   w.Show();
}

Running the app results in a window with a “MyNamespace.TestViewModel” string, instead of “TESTING”, which would infer my data template is not being found.

I am very new to all this so am I missing something obvious? I don’t think it’s a string matching issue since if I deliberately misspell the view or model in the XAML then it doesn’t compile.

Should my new window be able to access my app resources (and thus my datatemplate) ok?

Cheers,
Jeremy

EDIT: FIXED (Can’t answer for 8 hours)

Due to MS Bug where resources not being read unless at least one style is set.

See http://connect.microsoft.com/VisualStudio/feedback/details/553528/defaultstylekey-style-not-found-in-inner-mergeddictionaries

  • 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-22T17:41:59+00:00Added an answer on May 22, 2026 at 5:41 pm

    Due to MS Bug where resources not being read unless at least one style is set.

    See http://connect.microsoft.com/VisualStudio/feedback/details/553528/defaultstylekey-style-not-found-in-inner-mergeddictionaries

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

Sidebar

Related Questions

I'm trying to get my head around Caliburn.Micro and MVVM in a small test
I have been trying to wrap my head around mvvm for the last week
I'm trying to get my head around another issue i'm facing with my multi-tenant
I was trying to get my head around jQuery's Ajax. I have a page
I'm trying to get my head around to understand how to use closures in
I'm trying to get my head around how object lifetime and reference counting interact
I'm trying to get my head around this isReusable property of the IHttpHandler interface
I'm trying to get my head around how one would unit test an ASP.NET
I'm trying to get my head around jquery .has(). I tried to use it
I'm trying to get MVVMLight working on Windows Phone 7 and having a small

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.