Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

WPF - C# - Add Grid Panel to Window In Code Behind

Posted on 2010-11-26
2
1,184 Views
Last Modified: 2012-05-10
I am trying to dynamically create a window with a indeterminate progress bar in it. I can create a Grid panel and the progress bar. Then I add the progress bar as a child of the Grid panel. I just don'
t know how to add the Grid panel as a child of the Window.

Experts Can You Help???

Here is what I have so far:


private void btn_Click(object sender, RoutedEventArgs e)
        {
            Window window = new Window();
            window.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
            window.WindowStyle = System.Windows.WindowStyle.None;
            window.ResizeMode = System.Windows.ResizeMode.NoResize;
            window.Height = 50;
            window.Width = 150;
            window.Background = Brushes.AliceBlue;
            
            Grid grid = new Grid();

            // *** add grid as child to window *** //           

            ProgressBar pb = new ProgressBar();
            pb.IsIndeterminate = true;
            pb.Height = 30;
            pb.Width = 150;
            pb.Name = "pb";

            grid.Children.Add(pb);
            window.ShowDialog();
        }

Open in new window

0
Comment
Question by:bickes0724
2 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 500 total points
ID: 34222026
Sometimes things are so simple that they can be hidden:

window.Content = grid;
0
 

Author Closing Comment

by:bickes0724
ID: 34267566
Sorry it took so long to give you the point. Something more pressing was happening at work. Thanks again!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question