{"id":37447,"date":"2024-11-01T09:57:39","date_gmt":"2024-11-01T09:57:39","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=37447"},"modified":"2024-11-01T11:02:41","modified_gmt":"2024-11-01T11:02:41","slug":"uwp-development-collections","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/37447\/","title":{"rendered":"UWP Development, Collections"},"content":{"rendered":"<p><body><\/p>\n<article>\n<p>\n            Collections are a very important concept used in Universal Windows Platform (UWP) development to efficiently manage and display data. In this article, we will explain the basic concept of Collections in UWP development, the main collection types used, and provide example code utilizing these collections.\n        <\/p>\n<h2>1. Basic Concept of Collections<\/h2>\n<p>\n            Collections are data structures that allow multiple objects to be grouped and managed as a single unit. In UWP, classes like <code>ObservableCollection&lt;T&gt;<\/code>, <code>List&lt;T&gt;<\/code>, and <code>Dictionary&lt;TKey, TValue&gt;<\/code> are primarily used to implement collections. These collections are very useful for dynamically updating the user interface through data binding with the UI.\n        <\/p>\n<h2>2. Main Collection Classes<\/h2>\n<h3>2.1 ObservableCollection&lt;T&gt;<\/h3>\n<p>\n<code>ObservableCollection&lt;T&gt;<\/code> is a collection used to automatically notify the UI of changes in data. This collection ensures that the UI is updated automatically when items are added or removed, making it commonly used in UWP applications that follow the MVVM pattern.\n        <\/p>\n<h3>2.2 List&lt;T&gt;<\/h3>\n<p>\n<code>List&lt;T&gt;<\/code> is the most basic collection that stores a set of elements. While it is flexible and efficient, it does not directly support data binding as it does not synchronize with the UI. It is mainly used when complex data processing is required.\n        <\/p>\n<h3>2.3 Dictionary&lt;TKey, TValue&gt;<\/h3>\n<p>\n<code>Dictionary&lt;TKey, TValue&gt;<\/code> represents a set of key-value pairs and is useful when data retrieval is needed. This collection allows quick value retrieval via its keys.\n        <\/p>\n<h2>3. Example: A Simple Todo List Application Using ObservableCollection<\/h2>\n<p>\n            In this section, we will create a simple Todo List application using <code>ObservableCollection&lt;T&gt;<\/code>. This application allows users to add and delete tasks.\n        <\/p>\n<h3>3.1 Data Model<\/h3>\n<p><code><\/p>\n<pre>\n    public class TodoItem\n    {\n        public string Title { get; set; }\n        public bool IsCompleted { get; set; }\n    }\n            <\/pre>\n<p><\/code><\/p>\n<h3>3.2 ViewModel Setup<\/h3>\n<p><code><\/p>\n<pre>\n    using System.Collections.ObjectModel;\n    using System.ComponentModel;\n\n    public class TodoViewModel : INotifyPropertyChanged\n    {\n        public ObservableCollection&lt;TodoItem&gt; Todos { get; set; }\n        \n        public TodoViewModel()\n        {\n            Todos = new ObservableCollection&lt;TodoItem&gt;();\n        }\n\n        public void AddTodo(string title)\n        {\n            Todos.Add(new TodoItem { Title = title, IsCompleted = false });\n            OnPropertyChanged(\"Todos\");\n        }\n\n        public void RemoveTodo(TodoItem todo)\n        {\n            Todos.Remove(todo);\n            OnPropertyChanged(\"Todos\");\n        }\n\n        public event PropertyChangedEventHandler PropertyChanged;\n        protected void OnPropertyChanged(string propertyName)\n        {\n            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));\n        }\n    }\n            <\/pre>\n<p><\/code><\/p>\n<h3>3.3 XAML UI Configuration<\/h3>\n<p>\n            Below is a XAML example that binds the previously defined <code>TodoViewModel<\/code> to configure the UI.\n        <\/p>\n<p><code><\/p>\n<pre>\n    &lt;Page\n        x:Class=\"TodoList.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:TodoList\"&gt;\n\n        &lt;Grid&gt;\n            &lt;StackPanel&gt;\n                &lt;TextBox x:Name=\"TodoInput\" Width=\"300\" PlaceholderText=\"Enter your task\" \/&gt;\n                &lt;Button Content=\"Add\" Click=\"AddButton_Click\" \/&gt;\n\n                &lt;ListBox ItemsSource=\"{x:Bind ViewModel.Todos, Mode=OneWay}\"&gt;\n                    &lt;ListBox.ItemTemplate&gt;\n                        &lt;DataTemplate&gt;\n                            &lt;StackPanel Orientation=\"Horizontal\"&gt;\n                                &lt;CheckBox IsChecked=\"{Binding IsCompleted}\"&gt;&lt;\/CheckBox&gt;\n                                &lt;TextBlock Text=\"{Binding Title}\" \/&gt;\n                                &lt;Button Content=\"Delete\" Click=\"RemoveButton_Click\" Tag=\"{Binding}\" \/&gt;\n                            &lt;\/StackPanel&gt;\n                        &lt;\/DataTemplate&gt;\n                    &lt;\/ListBox.ItemTemplate&gt;\n                &lt;\/ListBox&gt;\n            &lt;\/StackPanel&gt;\n        &lt;\/Grid&gt;\n    &lt;\/Page&gt;\n            <\/pre>\n<p><\/code><\/p>\n<h3>3.4 Code-behind: Button Click Events<\/h3>\n<p>\n            Implement button click event handlers to allow users to add or delete tasks.\n        <\/p>\n<p><code><\/p>\n<pre>\n    public sealed partial class MainPage : Page\n    {\n        public TodoViewModel ViewModel { get; set; }\n\n        public MainPage()\n        {\n            this.InitializeComponent();\n            ViewModel = new TodoViewModel();\n            DataContext = ViewModel;\n        }\n\n        private void AddButton_Click(object sender, RoutedEventArgs e)\n        {\n            var todoTitle = TodoInput.Text;\n            if (!string.IsNullOrEmpty(todoTitle))\n            {\n                ViewModel.AddTodo(todoTitle);\n                TodoInput.Text = string.Empty;\n            }\n        }\n\n        private void RemoveButton_Click(object sender, RoutedEventArgs e)\n        {\n            var button = (Button)sender;\n            var todoToRemove = (TodoItem)button.Tag;\n            ViewModel.RemoveTodo(todoToRemove);\n        }\n    }\n            <\/pre>\n<p><\/code><\/p>\n<h2>4. Performance Optimization of Collections<\/h2>\n<p>\n            When using collections in UWP, it&#8217;s also important to optimize performance. Particularly, in cases with large amounts of data or frequent updates, performance can be improved using the following methods.\n        <\/p>\n<h3>4.1 Using Virtualization<\/h3>\n<p>\nItem templates like <code>ListView<\/code> or <code>GridView<\/code> provide virtualization internally, loading only the items displayed on the screen into memory at once. This feature can be used to efficiently display large amounts of data.\n        <\/p>\n<h3>4.2 Utilizing CollectionChanged Event<\/h3>\n<p>\n<code>ObservableCollection&lt;T&gt;<\/code> uses the <code>CollectionChanged<\/code> event to notify the UI about changes in the collection. Thus, UI update optimization should be considered during large data changes.\n        <\/p>\n<h2>5. Conclusion<\/h2>\n<p>\n            Collections are essential for data management and UI updates in UWP development. Utilizing <code>ObservableCollection&lt;T&gt;<\/code> allows for immediate UI reactions to data changes, enabling effective structuring of applications through the MVVM pattern. It is hoped that utilizing Collections in UWP applications will provide a more engaging user experience.\n        <\/p>\n<\/article>\n<p><\/body><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Collections are a very important concept used in Universal Windows Platform (UWP) development to efficiently manage and display data. In this article, we will explain the basic concept of Collections in UWP development, the main collection types used, and provide example code utilizing these collections. 1. Basic Concept of Collections Collections are data structures that &hellip; <a href=\"https:\/\/atmokpo.com\/w\/37447\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;UWP Development, Collections&#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-37447","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, Collections - \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\/37447\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"UWP Development, Collections - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"Collections are a very important concept used in Universal Windows Platform (UWP) development to efficiently manage and display data. In this article, we will explain the basic concept of Collections in UWP development, the main collection types used, and provide example code utilizing these collections. 1. Basic Concept of Collections Collections are data structures that &hellip; \ub354 \ubcf4\uae30 &quot;UWP Development, Collections&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/37447\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:57:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:02:41+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=\"4\ubd84\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/atmokpo.com\/w\/37447\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37447\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"UWP Development, Collections\",\"datePublished\":\"2024-11-01T09:57:39+00:00\",\"dateModified\":\"2024-11-01T11:02:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37447\/\"},\"wordCount\":426,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"UWP Programming\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/37447\/\",\"url\":\"https:\/\/atmokpo.com\/w\/37447\/\",\"name\":\"UWP Development, Collections - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:57:39+00:00\",\"dateModified\":\"2024-11-01T11:02:41+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37447\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/37447\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/37447\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"UWP Development, Collections\"}]},{\"@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, Collections - \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\/37447\/","og_locale":"ko_KR","og_type":"article","og_title":"UWP Development, Collections - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"Collections are a very important concept used in Universal Windows Platform (UWP) development to efficiently manage and display data. In this article, we will explain the basic concept of Collections in UWP development, the main collection types used, and provide example code utilizing these collections. 1. Basic Concept of Collections Collections are data structures that &hellip; \ub354 \ubcf4\uae30 \"UWP Development, Collections\"","og_url":"https:\/\/atmokpo.com\/w\/37447\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:57:39+00:00","article_modified_time":"2024-11-01T11:02:41+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":"4\ubd84"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/atmokpo.com\/w\/37447\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/37447\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"UWP Development, Collections","datePublished":"2024-11-01T09:57:39+00:00","dateModified":"2024-11-01T11:02:41+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/37447\/"},"wordCount":426,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["UWP Programming"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/37447\/","url":"https:\/\/atmokpo.com\/w\/37447\/","name":"UWP Development, Collections - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:57:39+00:00","dateModified":"2024-11-01T11:02:41+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/37447\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/37447\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/37447\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"UWP Development, Collections"}]},{"@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\/37447","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=37447"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/37447\/revisions"}],"predecessor-version":[{"id":37448,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/37447\/revisions\/37448"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=37447"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=37447"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=37447"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}