using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace WpfBaseApp4 { /// /// Interaction logic for _main.xaml /// public partial class MainWindow : Window { public MainWindow() { //InitializeComponent(); Method1(); } private void Method1() { // Create the application's main window // Since MainWindow is set to Hidden, only this window will visible Window _main = new System.Windows.Window(); _main.Title = "WrapPanel Sample"; _main.Height = 400; _main.Width = 400; // Instantiate a new WrapPanel objet and set properties WrapPanel myWrapPanel = new WrapPanel(); myWrapPanel.Background = System.Windows.Media.Brushes.Azure; myWrapPanel.Orientation = Orientation.Horizontal; myWrapPanel.Width = 200; myWrapPanel.HorizontalAlignment = HorizontalAlignment.Left; myWrapPanel.VerticalAlignment = VerticalAlignment.Top; Button btn1 = new Button(); btn1.Content = "Button 1"; btn1.Width = 75; Button btn2 = new Button(); btn2.Content = "Button 2"; btn2.Width = 75; Button btn3 = new Button(); btn3.Content = "Button 3"; btn3.Width = 75; Button btn4 = new Button(); btn4.Content = "Shutdown"; btn4.Click += Button4_Click; // Adds a click Event btn4.Width = 75; // Children.Add method. myWrapPanel.Children.Add(btn1); myWrapPanel.Children.Add(btn2); myWrapPanel.Children.Add(btn3); myWrapPanel.Children.Add(btn4); // Nesting WrapPanel in _main as Content _main.Content = myWrapPanel; _main.Show(); } private void Button4_Click(Object sender, RoutedEventArgs e) { App.Current.Shutdown(); } } }