forum

Home / DeveloperSection / Forums / Getting new line in wpf

Getting new line in wpf

Pravesh Singh 2026 23-Sep-2013

I am having arraylist.let say it contains 15 elements. I am adding these to stack panel. I need to add 3 elements per line. my code is below. I am getting either horizontal or verrtical.Let me know how to do this.

    MainWindow w;
    public ShopCart(MainWindow m,ArrayList _list)
    {                       
       InitializeComponent();
        w = m;
        int i = 1;
        foreach (string cartitems in _list)
        {
                mystackpanel.Orientation = Orientation.Horizontal;
                mystackpanel.Margin.Left.Equals(150);
                Label lbl = new Label();
                lbl.Name = "Label" + i;
                lbl.Height = 30;
                lbl.Width = 200;
                lbl.Margin.Left.Equals(150);
                //lbl.Margin.Top.Equals(150);
                lbl.Content = cartitems.ToString();
                mystackpanel.Children.Add(lbl);
                i++;
                int str = mystackpanel.Children.Count;
                MessageBox.Show(Convert.ToString(str));
                if (str%3 == 0)
                {
                    Button btndelete = new Button();
                    btndelete.Content = "Delete";
                    btndelete.Width = 120;
                    btndelete.Height = 35;
                    mystackpanel.Children.Add(btndelete);
mystackpanel.Margin.Top.Equals(500);
}
}


wpf wpf 
Updated on 23-Sep-2013

Can you answer this question?


Answer

1 Answers

Liked By