{"id":37613,"date":"2024-11-01T09:58:59","date_gmt":"2024-11-01T09:58:59","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=37613"},"modified":"2024-11-01T11:02:01","modified_gmt":"2024-11-01T11:02:01","slug":"uwp-development-change-the-output-order-of-repeated-buttons-in-the-body","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/37613\/","title":{"rendered":"UWP Development, Change the Output Order of Repeated Buttons in the Body"},"content":{"rendered":"<article>\n<p>UWP (Universal Windows Platform) is a platform provided by Microsoft for building applications on Windows 10 and later versions. With UWP, you can deliver a more consistent user experience across a variety of devices. In this article, we will explore in detail how to dynamically change the output order of repeating buttons among the UI components in UWP development. This will increase the flexibility of the user interface and help you learn to configure apps tailored to user needs.<\/p>\n<h2>1. Creating a UWP Project<\/h2>\n<p>First, you need to create a basic UWP project using Visual Studio. You can follow these steps:<\/p>\n<ol>\n<li>Run Visual Studio and select &lt;New Project&gt;.<\/li>\n<li>Search for &lt;UWP&gt; and select &lt;Blank App&gt; to create the project.<\/li>\n<li>Complete the project setup and click &lt;Create&gt;.<\/li>\n<\/ol>\n<h2>2. Basic UI Configuration in XAML<\/h2>\n<p>To configure the basic UI, open the XAML file and add controls to place the buttons that will be output repetitively. Here, we will use a <code>StackPanel<\/code> to list the buttons.<\/p>\n<pre><code>&lt;Page\n    x:Class=\"ButtonOrderApp.MainPage\"\n    xmlns=\"http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\/presentation\"\n    xmlns:x=\"http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\"\n    xmlns:local=\"using:ButtonOrderApp\"\n    xmlns:d=\"http:\/\/schemas.microsoft.com\/expression\/blend\/2008\"\n    xmlns:mc=\"http:\/\/schemas.openxmlformats.org\/markup-compatibility\/2006\"\n    mc:Ignorable=\"d\"&gt;\n\n    &lt;Grid Background=\"{ThemeResource ApplicationPageBackgroundThemeBrush}\"&gt;\n        &lt;StackPanel x:Name=\"ButtonPanel\" Orientation=\"Vertical\"&gt;\n\n        &lt;\/StackPanel&gt;\n    &lt;\/Grid&gt;\n    <\/code><\/pre>\n<h2>3. Creating and Outputting Buttons<\/h2>\n<p>To dynamically create buttons and add them to the StackPanel, write a method in C# code to create the buttons. Add the following code to the MainPage.xaml.cs file.<\/p>\n<pre><code>using Windows.UI.Xaml;\n    using Windows.UI.Xaml.Controls;\n    using System.Collections.Generic;\n    using System.Diagnostics;\n\n    namespace ButtonOrderApp\n    {\n        public sealed partial class MainPage : Page\n        {\n            private List<Button> buttons = new List<Button>();\n\n            public MainPage()\n            {\n                this.InitializeComponent();\n                CreateButtons();\n            }\n\n            private void CreateButtons()\n            {\n                for (int i = 1; i &lt;= 5; i++)\n                {\n                    Button button = new Button\n                    {\n                        Content = $\"Button {i}\",\n                        Name = $\"Button{i}\",\n                        Width = 200,\n                        Height = 100,\n                        Margin = new Thickness(5)\n                    };\n                    button.Click += Button_Click;\n                    ButtonPanel.Children.Add(button);\n                    buttons.Add(button);\n                }\n            }\n\n            private void Button_Click(object sender, RoutedEventArgs e)\n            {\n                Button clickedButton = sender as Button;\n                Debug.WriteLine($\"{clickedButton.Content} clicked\");\n            }\n        }\n    }\n    <\/code><\/pre>\n<h2>4. Changing the Output Order of Buttons<\/h2>\n<p>To change the output order of the buttons, we will add logic to move a specific button to the last position whenever a user clicks it. To do this, we will modify the <code>Button_Click<\/code> method.<\/p>\n<pre><code>private void Button_Click(object sender, RoutedEventArgs e)\n    {\n        \/\/ Move the clicked button to the end of the StackPanel\n        Button clickedButton = sender as Button;\n\n        \/\/ Remove the button from ButtonPanel\n        ButtonPanel.Children.Remove(clickedButton);\n\n        \/\/ Add the button to the end of ButtonPanel\n        ButtonPanel.Children.Add(clickedButton);\n        \n        \/\/ Output for the button click\n        Debug.WriteLine($\"{clickedButton.Content} clicked\");\n    }\n    <\/code><\/pre>\n<h2>5. Testing the App<\/h2>\n<p>Now that we have written all the code, let&#8217;s run the app to check its functionality. Press the F5 key to run the app in debug mode, and try clicking the buttons. The clicked button will move to the end of the list, changing the output order.<\/p>\n<h2>6. Code Explanation<\/h2>\n<p>To briefly explain the code:<\/p>\n<ul>\n<li><strong>CreateButtons<\/strong>: Creates buttons from 1 to 5 and adds them to the StackPanel.<\/li>\n<li><strong>Button_Click<\/strong>: This method is called when a button is clicked, removing the clicked button from the StackPanel and adding it again to change the order.<\/li>\n<\/ul>\n<h2>7. Additional Improvements<\/h2>\n<p>Currently, the order changes with each button click, but various enhancements could be added for more UI design diversity. For example:<\/p>\n<ul>\n<li>Add animations on button click<\/li>\n<li>Change the color or size of buttons to capture user visual interest<\/li>\n<li>Fix certain buttons to always remain in a designated position<\/li>\n<\/ul>\n<h2>8. Conclusion<\/h2>\n<p>In this post, we learned how to change the output order of repeating buttons using UWP. This was a good example demonstrating that dynamic UI behavior can be implemented with simple code. Such techniques can greatly help improve the user experience of an app. Practice the code and add your enhancements to develop an even better application.<\/p>\n<h2>9. References<\/h2>\n<ul>\n<li><a href=\"https:\/\/learn.microsoft.com\/en-us\/windows\/uwp\/get-started\/\">Getting Started with UWP<\/a><\/li>\n<li><a href=\"https:\/\/learn.microsoft.com\/en-us\/windows\/uwp\/design\/\">UWP Design Guidelines<\/a><\/li>\n<li><a href=\"https:\/\/learn.microsoft.com\/en-us\/windows\/uwp\/api\/windows.ui.xaml.controls.button\">Button Class Documentation<\/a><\/li>\n<\/ul>\n<\/article>\n","protected":false},"excerpt":{"rendered":"<p>UWP (Universal Windows Platform) is a platform provided by Microsoft for building applications on Windows 10 and later versions. With UWP, you can deliver a more consistent user experience across a variety of devices. In this article, we will explore in detail how to dynamically change the output order of repeating buttons among the UI &hellip; <a href=\"https:\/\/atmokpo.com\/w\/37613\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;UWP Development, Change the Output Order of Repeated Buttons in the Body&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[115],"tags":[],"class_list":["post-37613","post","type-post","status-publish","format-standard","hentry","category-uwp-programming"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>UWP Development, Change the Output Order of Repeated Buttons in the Body - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/atmokpo.com\/w\/37613\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"UWP Development, Change the Output Order of Repeated Buttons in the Body - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"UWP (Universal Windows Platform) is a platform provided by Microsoft for building applications on Windows 10 and later versions. With UWP, you can deliver a more consistent user experience across a variety of devices. In this article, we will explore in detail how to dynamically change the output order of repeating buttons among the UI &hellip; \ub354 \ubcf4\uae30 &quot;UWP Development, Change the Output Order of Repeated Buttons in the Body&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/37613\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:58:59+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:02:01+00:00\" \/>\n<meta name=\"author\" content=\"root\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:site\" content=\"@bebubo4\" \/>\n<meta name=\"twitter:label1\" content=\"\uae00\uc4f4\uc774\" \/>\n\t<meta name=\"twitter:data1\" content=\"root\" \/>\n\t<meta name=\"twitter:label2\" content=\"\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04\" \/>\n\t<meta name=\"twitter:data2\" content=\"3\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/37613\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37613\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"UWP Development, Change the Output Order of Repeated Buttons in the Body\",\"datePublished\":\"2024-11-01T09:58:59+00:00\",\"dateModified\":\"2024-11-01T11:02:01+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37613\/\"},\"wordCount\":467,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"UWP Programming\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/37613\/\",\"url\":\"https:\/\/atmokpo.com\/w\/37613\/\",\"name\":\"UWP Development, Change the Output Order of Repeated Buttons in the Body - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:58:59+00:00\",\"dateModified\":\"2024-11-01T11:02:01+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37613\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/37613\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/37613\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"UWP Development, Change the Output Order of Repeated Buttons in the Body\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/atmokpo.com\/w\/#website\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/atmokpo.com\/w\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"ko-KR\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\",\"name\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"url\":\"https:\/\/atmokpo.com\/w\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"contentUrl\":\"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png\",\"width\":400,\"height\":400,\"caption\":\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\"},\"image\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/bebubo4\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\",\"name\":\"root\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ko-KR\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g\",\"caption\":\"root\"},\"sameAs\":[\"http:\/\/atmokpo.com\/w\"],\"url\":\"https:\/\/atmokpo.com\/w\/author\/root\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"UWP Development, Change the Output Order of Repeated Buttons in the Body - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/atmokpo.com\/w\/37613\/","og_locale":"ko_KR","og_type":"article","og_title":"UWP Development, Change the Output Order of Repeated Buttons in the Body - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"UWP (Universal Windows Platform) is a platform provided by Microsoft for building applications on Windows 10 and later versions. With UWP, you can deliver a more consistent user experience across a variety of devices. In this article, we will explore in detail how to dynamically change the output order of repeating buttons among the UI &hellip; \ub354 \ubcf4\uae30 \"UWP Development, Change the Output Order of Repeated Buttons in the Body\"","og_url":"https:\/\/atmokpo.com\/w\/37613\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:58:59+00:00","article_modified_time":"2024-11-01T11:02:01+00:00","author":"root","twitter_card":"summary_large_image","twitter_creator":"@bebubo4","twitter_site":"@bebubo4","twitter_misc":{"\uae00\uc4f4\uc774":"root","\uc608\uc0c1 \ub418\ub294 \ud310\ub3c5 \uc2dc\uac04":"3\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/37613\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/37613\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"UWP Development, Change the Output Order of Repeated Buttons in the Body","datePublished":"2024-11-01T09:58:59+00:00","dateModified":"2024-11-01T11:02:01+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/37613\/"},"wordCount":467,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["UWP Programming"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/37613\/","url":"https:\/\/atmokpo.com\/w\/37613\/","name":"UWP Development, Change the Output Order of Repeated Buttons in the Body - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:58:59+00:00","dateModified":"2024-11-01T11:02:01+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/37613\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/37613\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/37613\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"UWP Development, Change the Output Order of Repeated Buttons in the Body"}]},{"@type":"WebSite","@id":"https:\/\/atmokpo.com\/w\/#website","url":"https:\/\/atmokpo.com\/w\/","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","description":"","publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/atmokpo.com\/w\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"ko-KR"},{"@type":"Organization","@id":"https:\/\/atmokpo.com\/w\/#organization","name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","url":"https:\/\/atmokpo.com\/w\/","logo":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/","url":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","contentUrl":"https:\/\/atmokpo.com\/w\/wp-content\/uploads\/2024\/11\/logo.png","width":400,"height":400,"caption":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8"},"image":{"@id":"https:\/\/atmokpo.com\/w\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/bebubo4"]},{"@type":"Person","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7","name":"root","image":{"@type":"ImageObject","inLanguage":"ko-KR","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/708197b41fc6435a7ce22d951b25d4a47e9e904270cb1f04682d4f025066f80c?s=96&d=mm&r=g","caption":"root"},"sameAs":["http:\/\/atmokpo.com\/w"],"url":"https:\/\/atmokpo.com\/w\/author\/root\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/37613","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/comments?post=37613"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/37613\/revisions"}],"predecessor-version":[{"id":37614,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/37613\/revisions\/37614"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=37613"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=37613"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=37613"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}