Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2010-11-26
2
Medium Priority
?
1,200 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 2000 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

927 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