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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:53:31+00:00 2026-05-13T12:53:31+00:00

I have a normal WPF window, let’s call it TopLevel which has a bunch

  • 0

I have a normal WPF window, let’s call it TopLevel which has a bunch of controls in it, among other things a simple ListView which should log certain events in different elements in the application.

So suppose I have a Grid in TopLevel which contains a bunch of user controls called Task. Each Task has an object associated with them as a public property, let’s call it Order, as well as a standard checkbox.

Now I want TopLevel to receive an event whenever the user checks a checkbox in a Task, but the event should contain the Order object as well, so I can work with it from TopLevel to put it into the event log.

How do I do that? I’m guessing I want to use routed events for it, but I can’t figure out how to get the checkbox click to “find” Order to send it upwards to TopLevel.

  • 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-13T12:53:31+00:00Added an answer on May 13, 2026 at 12:53 pm

    How about something like this…

    private void CheckBox_Checked(object sender, RoutedEventArgs e)
        {
            CheckBox checkBox = sender as CheckBox;
            Task task = FindParentTask(checkBox);
            Order order = task.Order;
        }
    

    Since you need to traverse up the visual tree to get to Task, you could try a bit of recursion…

    public FrameworkElement FindParentTask(FrameworkElement element)
        {
            if (element.Parent.GetType() == typeof(Task))
                return element.Parent as FrameworkElement;
            else
                return FindParentTask(element.Parent as FrameworkElement);
        }
    

    I’ve just tested this method to retrieve the parent Expander for a CheckBox on one of my UserControls, it’s several levels up the visual tree, nested in a heap of StackPanels, Grids and DockPanels, worked a treat.

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

Sidebar

Ask A Question

Stats

  • Questions 310k
  • Answers 310k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I used a similar pattern, but the helper was created… May 13, 2026 at 10:11 pm
  • Editorial Team
    Editorial Team added an answer You need to double escape virtually all of the functions… May 13, 2026 at 10:11 pm
  • Editorial Team
    Editorial Team added an answer You need to do this in code. Interface builder is… May 13, 2026 at 10:11 pm

Related Questions

I have a really weird thing happening in my wpf application. Every time I
I have a WPF window that I am launching from inside of a winform
I'm writing a modal dialog in WPF. How do I set a WPF window
I've created a WPF application where the title bar and chrome are turned off.
I am currently working on a little localization framework for WPF (don't even think

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.