{"id":1286,"date":"2023-05-08T16:26:35","date_gmt":"2023-05-08T08:26:35","guid":{"rendered":"https:\/\/white-night.club\/?p=1286"},"modified":"2024-09-29T20:14:30","modified_gmt":"2024-09-29T12:14:30","slug":"appdev1","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/05\/08\/appdev1\/","title":{"rendered":"WinUI3-&#8220;Hello World&#8221;"},"content":{"rendered":"\n<p>\u672c\u6587\u5c06\u901a\u8fc7&#8221;Hello World&#8221;\u7a0b\u5e8f\uff0c\u6982\u8ff0\u5176\u4e2d\u76f8\u5173\u77e5\u8bc6\u70b9\u3002<\/p>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>\u521b\u5efa\u684c\u9762\u5e94\u7528\u7a0b\u5e8f<\/p>\n<cite><em>&#8220;Click&#8221;<\/em><\/cite><\/blockquote>\n\n\n\n<p>VS\u4e2d\u5df2\u7ecf\u63d0\u4f9b\u4e86\u7a7a\u767d\u5e94\u7528\u7684\u6a21\u677f\uff0c\u76f4\u63a5\u521b\u5efa\u5373\u53ef\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large has-custom-border\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"680\" src=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/05\/1c06e8dd371ffe249933acc1d5669be-1024x680.png\" alt=\"\" class=\"wp-image-1294\" style=\"border-style:none;border-width:0px;border-radius:0px\" srcset=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/05\/1c06e8dd371ffe249933acc1d5669be-1024x680.png 1024w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/05\/1c06e8dd371ffe249933acc1d5669be-300x199.png 300w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/05\/1c06e8dd371ffe249933acc1d5669be-768x510.png 768w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/05\/1c06e8dd371ffe249933acc1d5669be.png 1280w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote has-vivid-cyan-blue-color has-text-color\">\n<p>\u5199\u8005\u6ce8<\/p>\n<cite>\u9700\u8981\u6ce8\u610f\u7684\u662fWinUI3\u662fVS2022\u65b0\u6dfb\u52a0\u7684\u3002\u50cf\u6211\u4e4b\u524d\u7528\u7684\u4e00\u76f4\u90fd\u662fVS2019\uff0c\u9700\u8981\u5148\u53bb\u628aVS\u66f4\u65b0\u52302022\uff0c\u518d\u6839\u636e\u5b98\u65b9\u6587\u6863\u53bb\u4e0b\u8f7d\u5bf9\u5e94\u7684\u7ec4\u4ef6\u3002\u4e0b\u8f7d\u7248\u672c\u7684\u8bdd\u53ef\u4ee5\u9009\u62e9\u514d\u8d39\u4f7f\u7528\u7684\u793e\u533a\u7248\u3002<\/cite><\/blockquote>\n\n\n\n<p>\u5f53\u7136\u7b2c\u4e00\u6b21\u8fdb\u5165\uff0c\u968f\u4fbf\u6253\u5f00\u4e00\u4e2a\u6587\u6863\u90fd\u80fd\u770b\u5230\u4e00\u5806\u62a5\u9519\u3002\u9700\u8981\u5148\u5728\u201c\u672c\u5730\u8ba1\u7b97\u673a\u201d\u4e0a\u8fd0\u884c\u4e00\u904d\uff0c\u76f4\u63a5\u70b9\u51fb\u201c\u672c\u5730\u8ba1\u7b97\u673a\u201d\u6216\u8005\u201c\u8c03\u8bd5\u201d\u6309\u94ae\u7136\u540e\u6162\u6162\u7b49\u5c31\u884c\uff0c\u7b2c\u4e00\u6b21\u8fd0\u884c\u65f6\u95f4\u4f1a\u6bd4\u8f83\u957f\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large has-custom-border\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"554\" src=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/05\/f1b021a7e79012b1658fdbd510d5992-1024x554.png\" alt=\"\" class=\"wp-image-1295\" style=\"border-style:none;border-width:0px;border-radius:0px\" srcset=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/05\/f1b021a7e79012b1658fdbd510d5992-1024x554.png 1024w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/05\/f1b021a7e79012b1658fdbd510d5992-300x162.png 300w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/05\/f1b021a7e79012b1658fdbd510d5992-768x416.png 768w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/05\/f1b021a7e79012b1658fdbd510d5992-1536x831.png 1536w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/05\/f1b021a7e79012b1658fdbd510d5992.png 1920w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>\u8fd0\u884c\u5b8c\u6210\u540e\u4f1a\u5f39\u51fa\u5e94\u7528\u754c\u9762\uff0c\u5982\u4e0b<\/p>\n\n\n\n<figure class=\"wp-block-image size-large has-custom-border\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"531\" src=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/05\/65b627336c5dec6dde18f406d847e16-1024x531.png\" alt=\"\" class=\"wp-image-1300\" style=\"border-style:none;border-width:0px;border-radius:0px\" srcset=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/05\/65b627336c5dec6dde18f406d847e16-1024x531.png 1024w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/05\/65b627336c5dec6dde18f406d847e16-300x156.png 300w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/05\/65b627336c5dec6dde18f406d847e16-768x398.png 768w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/05\/65b627336c5dec6dde18f406d847e16.png 1440w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>\u5b9e\u73b0\u201cHello World\u201d<\/p>\n<cite><em>MainWindow\u7c7b<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u6253\u5f00MainWindow.xaml\u6587\u4ef6\uff0c\u53ef\u4ee5\u770b\u5230\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;Window\n    x:Class=\"TestApp.MainWindow\"\n    xmlns=\"http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\/presentation\"\n    xmlns:x=\"http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\"\n    xmlns:local=\"using:TestApp\"\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;StackPanel Orientation=\"Horizontal\" HorizontalAlignment=\"Center\" VerticalAlignment=\"Center\"&gt;\n        &lt;Button x:Name=\"myButton\" Click=\"myButton_Click\"&gt;Click Me&lt;\/Button&gt;\n    &lt;\/StackPanel&gt;\n&lt;\/Window&gt;\n<\/code><\/pre>\n\n\n\n<p>\u6839\u636e\u6587\u4ef6\u540d\u5c31\u80fd\u63a8\u65ad\u51fa\uff0cMainWindow\u8868\u793a\u5e94\u7528\u6240\u663e\u793a\u7684\u4e3b\u7a97\u53e3\u3002\u5176\u5b9a\u4e49\u9690\u85cf\u5728MainWindow.xaml.cs\uff08C#\uff09\u6216MainWindow.xaml.h\u548c.cpp\uff08C++\uff09\u4e2d\u3002<\/p>\n\n\n\n<p>\u5176\u4e2dStackPanel\u7c7b\u53ef\u4ee5\u5c06\u5b50\u5143\u7d20\u6392\u6210\u6c34\u5e73\u6216\u5782\u76f4\u7684\u4e00\u6392\u3002\u201cHorizontal\u201d\u8bf4\u660e\u5c06\u5b50\u5143\u7d20\u6c34\u5e73\u6392\u5217\uff0c\u5982\u679c\u60f3\u6539\u6210\u6c34\u5e73\u6392\u5217\u76f4\u63a5\u6539\u6210&#8221;Vertical&#8221;\u5c31\u884c\u3002<\/p>\n\n\n\n<p>StackPanel\u5185\u90e8\u662f\u4e00\u4e2aButton\u7c7b\uff0c\u901a\u8fc7&#8221;myButton_Click&#8221;\u4ee5\u58f0\u660e\u65b9\u5f0f\u8fde\u63a5Click\u4e8b\u4ef6\u7684\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\u65b9\u6cd5\u3002\u8be5\u65b9\u6cd5\u53ef\u4ee5\u5728MainWindow.xaml.cs\u6216.cpp\u4e2d\u627e\u5230\u3002\u5176\u65b9\u6cd5\u4ee3\u7801\u5982\u4e0b\uff0c\u610f\u4e3a\u201c\u5c06Button\u7684\u5185\u5bb9\u6539\u4e3a\u201cClicked\u201d\u201d\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void MainWindow::myButton_Click(IInspectable const&amp;, RoutedEventArgs const&amp;)\n{\n     myButton().Content(box_value(L\"Clicked\"));\n}<\/code><\/pre>\n\n\n\n<p>\u800c\u8981\u8ba9\u7a0b\u5e8f\u663e\u793a\u201cHello World\u201d\uff0c\u9700\u8981\u7528\u5230TextBlock\u7c7b\u3002\u5176\u63d0\u4f9b\u7528\u4e8e\u663e\u793a\u5c11\u91cf\u6587\u672c\u7684\u8f7b\u578b\u63a7\u4ef6\u3002<\/p>\n\n\n\n<p>\u6211\u4eec\u9009\u62e9\u5c06StackPanel\u5bb9\u5668\u5185\u7684\u5143\u7d20\u5782\u76f4\u6392\u5217\uff0c\u540c\u65f6\u5141\u8bb8\u9f20\u6807\u9009\u4e2d\u6587\u672c\u5e76\u5c06\u9009\u4e2d\u7684\u6587\u672c\u9ad8\u4eae\u3002\u518d\u5c06\u6587\u672c\u7684\u5b57\u4f53\u683c\u5f0f\u6539\u4e0b\u3002\u6700\u540e\u66f4\u6539\u540e\u7684StackPanel\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;StackPanel Orientation=\"Vertical\" HorizontalAlignment=\"Center\" VerticalAlignment=\"Center\"&gt;\n        &lt;TextBlock Text=\"Hello World\"\/&gt;\n        &lt;TextBlock IsTextSelectionEnabled=\"True\" \n                   Text=\"\u5173\u6ce8\u6c38\u96cf\u5854\u83f2\u8c22\u8c22\u55b5\"     \n                   FontStyle=\"Oblique\" Width=\"240\"\n                   SelectionHighlightColor=\"Aquamarine\"           \n                   Foreground=\"PeachPuff\"\/&gt;\n        &lt;TextBlock\/&gt;\n    &lt;\/StackPanel&gt;<\/code><\/pre>\n\n\n\n<blockquote class=\"wp-block-quote has-vivid-cyan-blue-color has-text-color\">\n<p>\u5199\u8005\u6ce8<\/p>\n<cite>\u60f3\u8f93\u5165\u4e2d\u6587\u5b57\u7b26\u7684\u8bdd\uff0c\u8bb0\u5f97\u5728\u81ea\u5df1\u7535\u8111\u7cfb\u7edf\u4e2d\u7684\u8bed\u8a00\u8bbe\u7f6e\u4e2d\u52fe\u9009UTF-8\u7684Beta\u3002\u4e0d\u7136\u4f1a\u5bfc\u81f4\u7f16\u7801\u5bf9\u4e0d\u4e0a\u7136\u540e\u4e71\u7801\u3002<\/cite><\/blockquote>\n\n\n\n<p>\u4e0d\u8981\u5fd8\u4e86\u53bbMainWindow.xaml.cpp\u4e2d\u5220\u9664\u8fd9\u6bb5\u4ee3\u7801\u3002\u65e2\u7136\u4e0d\u9700\u8981Button\u90a3\u4e48\u5176\u5bf9\u5e94\u7684\u4e8b\u4ef6\u5904\u7406\u65b9\u6cd5\u4e5f\u8981\u5220\u6389\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>void MainWindow::myButton_Click(IInspectable const&amp;, RoutedEventArgs const&amp;)\n{\n     myButton().Content(box_value(L\"Clicked\"));\n}<\/code><\/pre>\n\n\n\n<p>\u8fd0\u884c\u7ed3\u679c\u5982\u4e0b\u56fe<\/p>\n\n\n\n<figure class=\"wp-block-image size-large has-custom-border\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"531\" src=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/05\/38d8723912e59294b8739a8e118f3c9-1024x531.png\" alt=\"\" class=\"wp-image-1301\" style=\"border-style:none;border-width:0px;border-radius:0px\" srcset=\"https:\/\/white-night.club\/wp-content\/uploads\/2023\/05\/38d8723912e59294b8739a8e118f3c9-1024x531.png 1024w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/05\/38d8723912e59294b8739a8e118f3c9-300x156.png 300w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/05\/38d8723912e59294b8739a8e118f3c9-768x398.png 768w, https:\/\/white-night.club\/wp-content\/uploads\/2023\/05\/38d8723912e59294b8739a8e118f3c9.png 1440w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u901a\u8fc7WinUI\u5b9e\u73b0&#8221;Hello World&#8221;\u7a0b\u5e8f<\/p>\n","protected":false},"author":1,"featured_media":1294,"comment_status":"open","ping_status":"","sticky":false,"template":"base","format":"standard","meta":{"footnotes":""},"categories":[52,51],"tags":[53,54],"_links":{"self":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/1286"}],"collection":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/comments?post=1286"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/1286\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media\/1294"}],"wp:attachment":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media?parent=1286"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=1286"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=1286"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}