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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:40:39+00:00 2026-05-19T22:40:39+00:00

I have a DataTemplate in app.xaml that binds a view to a viewmodel. <Application.Resources>

  • 0

I have a DataTemplate in app.xaml that binds a view to a viewmodel.

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

the above template doesn’t get applied if there are no styles. The moment I put a style, something like …

<Application.Resources>
    <DataTemplate DataType="{x:Type vm:someviewmodeltype}">
        <vw:somevwcontrol />
    </DataTemplate>
    <Style TargetType="TextBlock">
        <Setter Property="FontSize" Value="20"></Setter>
    </Style>
</Application.Resources>

datatemplate gets picked up and produces the desired results … I am not sure whats happening there … could anybody clarify this ?

Thanks.

  • 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-19T22:40:40+00:00Added an answer on May 19, 2026 at 10:40 pm

    Answered a similar question here. The question is not exactly the same, that one contained merged dictionaries being skipped but it’s most likely the same bug.

    This is an optimization bug, see this link.

    On the creation of every object in
    XAML, if a default style is present
    (i.e. style w/ a key of Type) that
    style should be applied. As you can
    imagine there are several performance
    optimizations to make that (implied)
    lookup a light weight as possible. One
    of them is that we don’t look inside
    Resource Dictionaries unless they are
    flagged as “containing default
    Styles”. There is a bug: if all your
    default styles are nested in merged
    dictionaries three levels deep (or
    deeper) the top dictionary does not
    get flagged so the search skips it.
    The work around is to put a default
    Style to something, anything, in the
    root Dictionary.

    I see you’ve already found the workaround as well, just add a default dummy style in App.xaml. It doesn’t have to have any setters etc, something like this will do as well

    <Application.Resources>
        <DataTemplate DataType="{x:Type vm:someviewmodeltype}">
            <vw:somevwcontrol />
        </DataTemplate>
        <Style TargetType="{x:Type Rectangle}" /> 
    </Application.Resources>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Well the problem here is that if you have one DataTemplate for a type
I have a DataTemplate that is displaying objects with three fields, e.g.: Name =
I have a listview with a DataTemplate that has a ComboBox. I want the
I have an <ItemsControl> with a custom <DataTemplate> (and also a custom <ItemsPanelTemplate> that
I have a WPF application that mostly follows MVVM, which I am trying to
I have an ItemsControl with a DataTemplate that is bound to an ObservableCollection of
I have a listbox with a datatemplate for the items. The problem is that
I have a new web app that is packaged as a WAR as part
To have less redundant XAML markup i try to get a radiobutton-type selection control
all. I have an app that scans a picture folder and displays the images

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.