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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T23:56:42+00:00 2026-05-15T23:56:42+00:00

I am developing a UserControl, call it CoolControl, that is meant to act somewhat

  • 0

I am developing a UserControl, call it CoolControl, that is meant to act somewhat like a window, with a few special features. So far, it can be resized and dragged all around the screen. If I add multiple CoolControl objects to my application window using XAML, the last one that was declared is always in front. This is fine, but I want to make it so that if I click on one of my CoolControl objects during run-time, that control will put itself in front of all the other controls.

I’ve tried using Canvas.SetZIndex, but unless I’m simply unable to come up with a clever enough solution, I don’t see how that can help me. Because once I set one control’s Z-Index to 9999, over time every other control I click will have the same value of 9999. And then, once again, the control declared last ends up in front.

If you were given the task of writing a BringToFront() method for someone’s UserControl, how would you do it in the simplest way possible? I’d prefer a better solution than getting the parent window, looping through all the controls, finding the maximum Z-Index, and then setting the Z-Index of the CoolControl accordingly, if THAT is even a valid solution.

  • 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-15T23:56:43+00:00Added an answer on May 15, 2026 at 11:56 pm

    I’m not familiar with the Canvas.SetZIndex method. It looks like some sort of attached property or behaviour.

    If you can provide the logic to set the z-index, I’ve outlined a way to keep track of the instances and manage the z-indexes, keeping them in the order in which they have been selected/created.

    public class CoolControl : UserControl
    {
    
        public CoolControl()
        {
            InitializeComponent();
            Instances.Add(this);
        }
    
        static IList<CoolControl> Instances = new List<CoolControl>();
    
        void SelectThisInstance()
        {
            foreach(var instance in Instances)
            {
                // decrement z-index instance
            }
    
            // set z-index of this instance to show at top
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Developing a .NET WinForms application: how can I check if the window is in
newbie question, please forgive... I'm developing a Wpf UserControl that will eventually be bound
I am developing controls for WP7 application. I am aware that I can quickly
I'm working with WPF and I'm developing a complex usercontrol, which is composed of
I developing a usercontrol in csharp in which i will be using a textbox
I'm developing this usercontrol which requires I override the WndProc of the control's parent
Developing a web application that I've registered with Twitter. In this app, I might
Developing a little survey webapp, ran into problem that deals with ranges for rating
I am currently developing an application in which I want to display a UserControl
I'm developing on a site with a few hundred user controls. When debugging the

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.