Last active
September 12, 2023 13:20
-
-
Save jTakasuRyuji/f8b93603c017cea61acb77a0c39a375a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <StackPanel Name="myStackPanel"> | |
| <!-- ここにコントロールを配置します --> | |
| </StackPanel> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Windows.UI.Xaml.Controls; | |
| public sealed partial class MainPage : Page | |
| { | |
| public MainPage() | |
| { | |
| this.InitializeComponent(); | |
| // ボタンの配列を作成し、myStackPanel に追加 | |
| for (int i = 0; i < 5; i++) | |
| { | |
| Button button = new Button(); | |
| button.Content = $"ボタン {i + 1}"; | |
| myStackPanel.Children.Add(button); | |
| } | |
| } | |
| button.Click += Button_Click; | |
| private void Button_Click(object sender, RoutedEventArgs e) | |
| { | |
| // ボタンがクリックされたときの処理をここに追加 | |
| } | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
UWPでコントロール配列を使いたい