728x90
반응형
WPF & C# - Button 생성 함수 정리 ( btn / 버튼 / Create ) |
MainWindow.xaml.cs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | private Button CreateButton(string Name=null, string Tag=null, string Content=null, Double Width = 75, Double Height = 20) { // 버튼 생성 Button btn = new Button(); // 버튼 생성 btn.Name = Name; // 버튼명 // 버튼 생성 - 모양및 색상 btn.Content = Content; // 버튼 Content btn.Tag = Tag; // tag btn.Height = Height; // 세로길이 btn.Width = Width; // 가로길이 /* // 버튼 색상 btn.Background = new SolidColorBrush(Color.FromArgb(255, 0, 80, 80)); // 배경 btn.Foreground = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255)); // 글씨색 */ // 버튼 생성 - 이벤트 등록 btn.Click += (s, e) => { // }; /* // 버튼 생성 - 위치 btn.HorizontalAlignment = HorizontalAlignment.Left; // 정렬 기준 좌측 btn.VerticalAlignment = VerticalAlignment.Top; // 정렬 기준 상측 btn.Margin = new Thickness(btn.Width * (i % 10), btn.Height * (i / 10), 0, 0); // 위치 grid1.Children.Add(btn); // grid1 에 넣기 */ return btn; } | cs |
728x90
반응형