Solved

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

Posted on 2010-11-26
2
1,172 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
Comment Utility
Sometimes things are so simple that they can be hidden:

window.Content = grid;
0
 

Author Closing Comment

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

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Bit flags and bit flag manipulation is perhaps one of the most underrated strategies in programming, likely because most programmers developing in high-level languages rely too much on the high-level features, and forget about the low-level ones. Th…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

728 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now