با عرض سلام و خسته نباشید خدمت کاربران وب سایت پروگرم 98 😉 در این مطلب کد افزودن چند دکمه با حلقه for درون یک StackPanel با wpf و سی شارپ #C را آماده کردم. امیدوارم که این کد برای شما مفید باشد.
کد افزودن چند دکمه با حلقه for درون یک StackPanel با wpf و سی شارپ #C :
using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
class MainClass : Window
{
[STAThread]
public static void Main()
{
Application app = new Application();
app.Run(new MainClass());
}
public MainClass()
{
StackPanel stack = new StackPanel();
Content = stack;
for (int i = 0; i < 10; i++)
{
Button btn = new Button();
btn.Name = i.ToString();
btn.FontSize += 10;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
class MainClass : Window
{
[STAThread]
public static void Main()
{
Application app = new Application();
app.Run(new MainClass());
}
public MainClass()
{
StackPanel stack = new StackPanel();
Content = stack;
for (int i = 0; i < 10; i++)
{
Button btn = new Button();
btn.Name = i.ToString();
btn.FontSize += 10;