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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:33:07+00:00 2026-06-18T12:33:07+00:00

Let’s jump right in and let the code explain: FrameworkElement par = list; while((par

  • 0

Let’s jump right in and let the code explain:

            FrameworkElement par = list;
        while((par = par.Parent as FrameworkElement) != null) {
            grid.Resources.MergedDictionaries.Add(par.Resources);
        }
        grid.DataContext = list.DataContext;
        if(rootparent is ContentControl) {
            (rootparent as ContentControl).Content = null;
        } else if(rootparent is Decorator) {
            (rootparent as Decorator).Child = null;
        } else if(rootparent is Panel) {
            rootindex = (rootparent as Panel).Children.IndexOf(list);
            (rootparent as Panel).Children.RemoveAt(rootindex);
        }
        grid.Children.Add(list);

So, basically, the templated control is moved out of its original window and into an instantiated grid in the background. Its datacontext successfully transfers (I watched it go to null when it disconnected, and back to the original object when it joined the grid), but the templates don’t. I don’t get why, because up there at the top I’m copying all the resource dictionaries all the way to the top-level parent and merging them into the new grid.

So I’m missing something in making it re-apply the templates.

  • 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-18T12:33:09+00:00Added an answer on June 18, 2026 at 12:33 pm

    The resources needed to be duplicated into the new container, not just referenced.

    FrameworkElement par = list;
    while((par = par.Parent as FrameworkElement) != null) {
        DictionaryEntry[] resources = new DictionaryEntry[par.Resources.Count];
        par.Resources.CopyTo(resources, 0);
        var res = new ResourceDictionary();
        foreach(DictionaryEntry ent in resources)
            res.Add(ent.Key, ent.Value);
        grid.Resources.MergedDictionaries.Add(res);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let me explain best with an example. Say you have node class that can
Let me try to explain by example. Say website is hosted at example.com (NOT
Let's say I have a sortable list like this: $(.song-list).sortable({ handle : '.pos_handle', axis
Let's say I have the following entity: public class Store { public List<Product> Products
Let's say I have an abstract parent class called shape, and that there are
Let me give an example and try to explain what I want to ask:
Let say I have a grid , <Grid Name=grid1> <Grid.ColumnDefinitions> <ColumnDefinition Name=col1 Width=auto> </ColumnDefinition>
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
Let me explain my problem. I have 3 UIView : a LoginView , LibraryView
Let's have an example like below: package xliiv.sandbox; import android.app.Activity; import android.os.Bundle; import android.util.Log;

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.