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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:23:56+00:00 2026-05-12T19:23:56+00:00

I have a question related to this one : I’m trying to attach an

  • 0

I have a question related to this one: I’m trying to attach an event to my StackPanel but it doesn’t appear to connect when using the XamlReader. I can’t get the ChildItem_Load method to get called. Does anyone know of a way to do this?

Other than this event the code works fine.

this._listBox.ItemTemplate = (DataTemplate) XamlReader.Load(
                    @"<DataTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation"">
                          <Border>
                              <StackPanel Loaded=""ChildItem_Loaded"">
                                  <TextBlock Text=""{Binding " + this._displayMemberPath + @"}"" />
                              </StackPanel>
                          </Border>
                      </DataTemplate>"
  • 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-12T19:23:57+00:00Added an answer on May 12, 2026 at 7:23 pm

    Ok, I figured out a bit of a ‘hack’ solution, but it works.

    Since it looks like the XamlReader doesn’t have any knowledge of the local namespace when creating the DataTemplate I extended the StackPanel and “baked-in” the Load event. It’s not exactly ideal, but it works:

    this._listBox.ItemTemplate = (DataTemplate) XamlReader.Load(
        @"<DataTemplate xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
                        xmlns:foo=""clr-namespace:Foo;assembly=Foo"">
             <Border>
                 <foo:ExtendedStackPanel>
                     <TextBlock Text=""{Binding " + this._displayMemberPath + @"}"" />
                 </foo:ExtendedStackPanel>
             </Border>
         </DataTemplate>"
        );
    

    And the extended class:

    public class ExtendedStackPanel : StackPanel
    {
        public ExtendedStackPanel() : base()
        {
            this.Loaded += new RoutedEventHandler(this.ChildItem_Loaded);
        }
    
        private void ChildItem_Loaded(object sender, RoutedEventArgs e)
        {
            // Logic here...
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is related to my previous question , but a different one. I have
I have a question related to this one . I don't want to do
Another question related to this one . I have a List<SortableObjects> that is the
this time i have a simple question: I have one table, related with himself
This question is related to this one , but simpler. [I think I may
(This question is related - but not the same - to this one) This
This question is related to this one . I have two constructors: - (id)initWithBanner:(NSMutableArray
This question is related to this one but I think should be asked separately.
I have one more question related to this thread. How to decode some number
This is related question to my previous question but different one. After searching a

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.