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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:46:21+00:00 2026-05-23T07:46:21+00:00

I am using the ChildWindow (Silverlight) which also contains some expander controls. In one

  • 0

I am using the ChildWindow (Silverlight) which also contains some expander controls. In one case, when the expander control expands, the bottom of the child window expands down out the screen on the bottom, but still leaves room on the top.

How can I re-position a child window in order to center it in the screen, as if I just opened the childwindow? (That would be easy, but I don’t think doable)

(manual intervention)
I’ve gone through RenderTransform of the the ContentRoot, and I have six transforms in that collection, 2 of which are TranslateTransforms. If I update the X/Y properties of the first one (don’t know which of the two I should be changing) AND update the RenderTransform property with the entire TransformGroup, I have success in moving the ChildWindow around the screen – but it’s not behaving as I am expecting.

I also dont’ know why the ChildWindow_SizeChanged event does not fire, when the Expander control expands. The window does change in size, so why does it not fire?

Ok – too many questions, just need the first one answered, the rest are to fill in my knowledge of how WPF/Silverlight is working…

Regards,
Richard

  • 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-23T07:46:22+00:00Added an answer on May 23, 2026 at 7:46 am

    Answer via this blog: http://www.kunal-chowdhury.com/2010/11/how-to-reposition-silverlight-child.html

    /// <summary>
    /// Centers the Silverlight ChildWindow in screen.
    /// </summary>
    /// <remarks>
    /// 1) Visual TreeHelper will grab the first element within a ChildWindow - this is the Chrome (Title Bar, Close button, etc.)
    /// 2) ContentRoot - is the first element within that Chrome for a ChildWindow - which is named this within the template of the control (Childwindow)
    /// 3) Using the container (named ContentRoot), pull out all the "Transforms" which move, or alter the layout of a control
    ///   TranslateTransform - provides X,Y coordinates on where the control should be positioned
    /// 4) Using a Linq expression, grab teh last TransLateTransfrom from the TransformGroup
    /// 5) Reset the TranslateTransform to point 0,0 which should reference the ChildWindow to be the upper left of the window.  However, this is setting
    ///    is probably overridden by a default behaviour to always reset the window window to the middle of the screen based on it's size, and the size of the browser
    ///    I would have liked to animate this, but this likely requires a storyboard event that I don't have time for at this moment.
    ///    
    /// This entire process to move, or alter a window in WPF was a total learning experience.
    /// </remarks>
    /// <param name="childWindow">The child window.
    public static void CenterInScreen(this ChildWindow childWindow)
    {
      var root = VisualTreeHelper.GetChild(childWindow, 0) as FrameworkElement;
      if (root == null) { return; }
    
      var contentRoot = root.FindName("ContentRoot") as FrameworkElement;
      if (contentRoot == null) { return; }
    
      var transformgroup = contentRoot.RenderTransform as TransformGroup;
      if (transformgroup == null) { return; }
    
      TranslateTransform transform = transformgroup.Children.OfType<TranslateTransform>().LastOrDefault();
      if (transform == null) { return; }
    
      transform.X = 0;
      transform.Y = 0;
    
    }
    

    }

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

Sidebar

Related Questions

I have this function which is supposed to open up a child window using
I'm using a style for my child window in my Silverlight application. It seems
Using online interfaces to a version control system is a nice way to have
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
If I show a new non-modal child window using .Show(frmParent), and then the parent
Is it possible to refresh parent page from child's child page using javascript. I
I have the following code in child window which is working but what I
I'm getting some very strange date formatting issues in my Silverlight application. My local
I am using this code to update the database while the child browser window
I am trying to close parent window from child window using javascript, but its

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.