{"id":37685,"date":"2024-11-01T09:59:34","date_gmt":"2024-11-01T09:59:34","guid":{"rendered":"http:\/\/atmokpo.com\/w\/?p=37685"},"modified":"2024-11-01T11:04:09","modified_gmt":"2024-11-01T11:04:09","slug":"wpf-development-understanding-xaml","status":"publish","type":"post","link":"https:\/\/atmokpo.com\/w\/37685\/","title":{"rendered":"WPF Development, Understanding XAML"},"content":{"rendered":"<article>\n<p>\n        Windows Presentation Foundation (WPF) is a graphics subsystem developed by Microsoft, providing a powerful platform for developing modern Windows applications. One of the most notable features of WPF is XAML (Extensible Application Markup Language), which is used to define the user interface. XAML allows for the declarative definition of UI elements and their properties.\n    <\/p>\n<h2>1. Basics of XAML<\/h2>\n<p>\n        XAML is an XML-based markup language used to construct the UI of applications in WPF. By using XAML, the readability of the code is improved, making collaboration between designers and developers easier. A basic XAML document has the following structure.\n    <\/p>\n<pre>\n        <code>\n            &lt;Window x:Class=\"MyApp.MainWindow\"\n                    xmlns=\"http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\/presentation\"\n                    xmlns:x=\"http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\"\n                    Title=\"MainWindow\" Height=\"350\" Width=\"525\"&gt;\n                &lt;Grid&gt;\n                    &lt;Button Name=\"MyButton\" Content=\"Click Me\" \/&gt;\n                &lt;\/Grid&gt;\n            &lt;\/Window&gt;\n        <\/code>\n    <\/pre>\n<h3>1.1. Elements and Properties<\/h3>\n<p>\n        When defining UI elements within a XAML document, each element is created with a tag, and properties are specified within the tag. In the example above, the &lt;Button&gt; element uses the Content property to specify the text of the button.\n    <\/p>\n<h2>2. Advantages of XAML<\/h2>\n<p>\n        Using XAML in WPF applications has several advantages. First, XAML allows UI elements to be defined more quickly and intuitively. Second, XAML is very useful for defining bindings, styles, resources, and more. Finally, using XAML makes collaboration between UI designers and developers much smoother.\n    <\/p>\n<h2>3. Basic Syntax of XAML<\/h2>\n<p>\n        The basic syntax of XAML is similar to XML. Each UI element consists of a start tag and an end tag, with properties defined as pairs of property names and values. For example, the following is XAML that defines a basic TextBox.\n    <\/p>\n<pre>\n        <code>\n            &lt;TextBox Width=\"200\" Height=\"30\" \/&gt;\n        <\/code>\n    <\/pre>\n<h3>3.1. Specifying Property Values<\/h3>\n<p>\n        Property values can be specified in several formats. In addition to typical property values, colors, sizes, alignments, and more can be defined. For example, here is a Button definition that includes various colors and alignments.\n    <\/p>\n<pre>\n        <code>\n            &lt;Button Content=\"Press Me\" Background=\"Blue\" Foreground=\"White\" HorizontalAlignment=\"Center\" \/&gt;\n        <\/code>\n    <\/pre>\n<h2>4. Data Binding<\/h2>\n<p>\n        One of the important features of XAML is data binding. Data binding allows for easy establishment of a connection between UI elements and data models. For instance, you can bind a ViewModel&#8217;s property to the UI so that users can change data via the UI.\n    <\/p>\n<pre>\n        <code>\n            &lt;TextBox Text=\"{Binding Name, UpdateSourceTrigger=PropertyChanged}\" \/&gt;\n        <\/code>\n    <\/pre>\n<p>\n        In the example above, the Text property of the TextBox is bound to the Name property of the ViewModel. When the user types into the TextBox, the Name property of the ViewModel is automatically updated.\n    <\/p>\n<h2>5. Styles and Templates<\/h2>\n<p>\n        In WPF, styles and templates can be used to easily set the appearance and behavior of UI elements. Styles group and make reusable the properties of UI elements. For instance, you can specify a common style for all buttons.\n    <\/p>\n<pre>\n        <code>\n            &lt;Window.Resources&gt;\n                &lt;Style TargetType=\"Button\"&gt;\n                    &lt;Setter Property=\"Background\" Value=\"LightGray\"\/&gt;\n                    &lt;Setter Property=\"Foreground\" Value=\"Black\"\/&gt;\n                &lt;\/Style&gt;\n            &lt;\/Window.Resources&gt;\n        <\/code>\n    <\/pre>\n<h3>5.1. Custom Templates<\/h3>\n<p>\n        Custom templates allow you to redefine the basic structure of UI elements. For example, if you want to change the default appearance of a button, you can define a ControlTemplate like this.\n    <\/p>\n<pre>\n        <code>\n            &lt;Button Content=\"Custom Button\"&gt;\n                &lt;Button.Template&gt;\n                    &lt;ControlTemplate TargetType=\"Button\"&gt;\n                        &lt;Border Background=\"Orange\" CornerRadius=\"10\"&gt;\n                            &lt;ContentPresenter \/&gt;\n                        &lt;\/Border&gt;\n                    &lt;\/ControlTemplate&gt;\n                &lt;\/Button.Template&gt;\n            &lt;\/Button&gt;\n        <\/code>\n    <\/pre>\n<h2>6. Resource Management in XAML<\/h2>\n<p>\n        In WPF, resources can be used to reuse various elements such as colors, styles, and textures. Resources can be stored in the Resources property of a Window, UserControl, or Application class.\n    <\/p>\n<pre>\n        <code>\n            &lt;Window.Resources&gt;\n                &lt;SolidColorBrush x:Key=\"MyBrush\" Color=\"Red\" \/&gt;\n            &lt;\/Window.Resources&gt;\n            &lt;Button Background=\"{StaticResource MyBrush}\" Content=\"Red Button\" \/&gt;\n        <\/code>\n    <\/pre>\n<h2>7. XAML and Code-Behind<\/h2>\n<p>\n        WPF applications are defined primarily by XAML for the UI, while C# code-behind handles the application&#8217;s logic and event handling. The code-behind associated with a XAML file is defined by the class specified in the &#8216;x:Class&#8217; attribute.\n    <\/p>\n<pre>\n        <code>\n            public partial class MainWindow : Window\n            {\n                public MainWindow()\n                {\n                    InitializeComponent();\n                }\n\n                private void MyButton_Click(object sender, RoutedEventArgs e)\n                {\n                    MessageBox.Show(\"Button clicked!\");\n                }\n            }\n        <\/code>\n    <\/pre>\n<p>\n        The Click event of the Button defined in XAML can be handled in C# code. Event handling for the user interface mainly occurs in the code-behind.\n    <\/p>\n<h2>8. Optimization of XAML<\/h2>\n<p>\n        It is also important to write and optimize XAML efficiently. Excessive use of UI elements can lead to performance degradation, and to avoid this, consider the following methods:\n    <\/p>\n<ul>\n<li>Use resources to consistently manage styles and designs<\/li>\n<li>Utilize data templates to optimize data binding<\/li>\n<li>Avoid duplication of UI elements and create components only when necessary<\/li>\n<\/ul>\n<h2>9. Conclusion<\/h2>\n<p>\n        XAML plays a crucial role in WPF development, serving as an essential tool for effectively designing and implementing user interfaces. By understanding XAML, you can apply various features of WPF more effectively and significantly enhance development efficiency through the separation of UI design and code. I hope this article has helped you understand the basics and applications of XAML well, and that you will utilize it in real development.\n    <\/p>\n<\/article>\n","protected":false},"excerpt":{"rendered":"<p>Windows Presentation Foundation (WPF) is a graphics subsystem developed by Microsoft, providing a powerful platform for developing modern Windows applications. One of the most notable features of WPF is XAML (Extensible Application Markup Language), which is used to define the user interface. XAML allows for the declarative definition of UI elements and their properties. 1. &hellip; <a href=\"https:\/\/atmokpo.com\/w\/37685\/\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;WPF Development, Understanding XAML&#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":[117],"tags":[],"class_list":["post-37685","post","type-post","status-publish","format-standard","hentry","category-wpf-programming"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.2 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>WPF Development, Understanding XAML - \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\/37685\/\" \/>\n<meta property=\"og:locale\" content=\"ko_KR\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"WPF Development, Understanding XAML - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"og:description\" content=\"Windows Presentation Foundation (WPF) is a graphics subsystem developed by Microsoft, providing a powerful platform for developing modern Windows applications. One of the most notable features of WPF is XAML (Extensible Application Markup Language), which is used to define the user interface. XAML allows for the declarative definition of UI elements and their properties. 1. &hellip; \ub354 \ubcf4\uae30 &quot;WPF Development, Understanding XAML&quot;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/atmokpo.com\/w\/37685\/\" \/>\n<meta property=\"og:site_name\" content=\"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\" \/>\n<meta property=\"article:published_time\" content=\"2024-11-01T09:59:34+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-11-01T11:04:09+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\/37685\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37685\/\"},\"author\":{\"name\":\"root\",\"@id\":\"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7\"},\"headline\":\"WPF Development, Understanding XAML\",\"datePublished\":\"2024-11-01T09:59:34+00:00\",\"dateModified\":\"2024-11-01T11:04:09+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37685\/\"},\"wordCount\":666,\"publisher\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#organization\"},\"articleSection\":[\"WPF Programming\"],\"inLanguage\":\"ko-KR\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/atmokpo.com\/w\/37685\/\",\"url\":\"https:\/\/atmokpo.com\/w\/37685\/\",\"name\":\"WPF Development, Understanding XAML - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8\",\"isPartOf\":{\"@id\":\"https:\/\/atmokpo.com\/w\/#website\"},\"datePublished\":\"2024-11-01T09:59:34+00:00\",\"dateModified\":\"2024-11-01T11:04:09+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/atmokpo.com\/w\/37685\/#breadcrumb\"},\"inLanguage\":\"ko-KR\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/atmokpo.com\/w\/37685\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/atmokpo.com\/w\/37685\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\ud648\",\"item\":\"https:\/\/atmokpo.com\/w\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"WPF Development, Understanding XAML\"}]},{\"@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":"WPF Development, Understanding XAML - \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\/37685\/","og_locale":"ko_KR","og_type":"article","og_title":"WPF Development, Understanding XAML - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","og_description":"Windows Presentation Foundation (WPF) is a graphics subsystem developed by Microsoft, providing a powerful platform for developing modern Windows applications. One of the most notable features of WPF is XAML (Extensible Application Markup Language), which is used to define the user interface. XAML allows for the declarative definition of UI elements and their properties. 1. &hellip; \ub354 \ubcf4\uae30 \"WPF Development, Understanding XAML\"","og_url":"https:\/\/atmokpo.com\/w\/37685\/","og_site_name":"\ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","article_published_time":"2024-11-01T09:59:34+00:00","article_modified_time":"2024-11-01T11:04:09+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\/37685\/#article","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/37685\/"},"author":{"name":"root","@id":"https:\/\/atmokpo.com\/w\/#\/schema\/person\/91b6b3b138fbba0efb4ae64b1abd81d7"},"headline":"WPF Development, Understanding XAML","datePublished":"2024-11-01T09:59:34+00:00","dateModified":"2024-11-01T11:04:09+00:00","mainEntityOfPage":{"@id":"https:\/\/atmokpo.com\/w\/37685\/"},"wordCount":666,"publisher":{"@id":"https:\/\/atmokpo.com\/w\/#organization"},"articleSection":["WPF Programming"],"inLanguage":"ko-KR"},{"@type":"WebPage","@id":"https:\/\/atmokpo.com\/w\/37685\/","url":"https:\/\/atmokpo.com\/w\/37685\/","name":"WPF Development, Understanding XAML - \ub77c\uc774\ube0c\uc2a4\ub9c8\ud2b8","isPartOf":{"@id":"https:\/\/atmokpo.com\/w\/#website"},"datePublished":"2024-11-01T09:59:34+00:00","dateModified":"2024-11-01T11:04:09+00:00","breadcrumb":{"@id":"https:\/\/atmokpo.com\/w\/37685\/#breadcrumb"},"inLanguage":"ko-KR","potentialAction":[{"@type":"ReadAction","target":["https:\/\/atmokpo.com\/w\/37685\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/atmokpo.com\/w\/37685\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\ud648","item":"https:\/\/atmokpo.com\/w\/en\/"},{"@type":"ListItem","position":2,"name":"WPF Development, Understanding XAML"}]},{"@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\/37685","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=37685"}],"version-history":[{"count":1,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/37685\/revisions"}],"predecessor-version":[{"id":37686,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/posts\/37685\/revisions\/37686"}],"wp:attachment":[{"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/media?parent=37685"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/categories?post=37685"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/atmokpo.com\/w\/wp-json\/wp\/v2\/tags?post=37685"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}