{"id":1132,"date":"2019-11-02T17:24:07","date_gmt":"2019-11-02T09:24:07","guid":{"rendered":"http:\/\/iqotom.com\/?p=1132"},"modified":"2019-11-02T17:24:09","modified_gmt":"2019-11-02T09:24:09","slug":"wpf%e5%ae%9e%e7%8e%b0%e5%a4%9a%e8%af%ad%e8%a8%80%e6%94%af%e6%8c%81-%e5%8a%a8%e6%80%81%e5%8a%a0%e8%bd%bd%e8%b5%84%e6%ba%90%e8%af%8d%e5%85%b8","status":"publish","type":"post","link":"http:\/\/iqotom.com\/?p=1132","title":{"rendered":"WPF\u5b9e\u73b0\u591a\u8bed\u8a00\u652f\u6301 \u52a8\u6001\u52a0\u8f7d\u8d44\u6e90\u8bcd\u5178"},"content":{"rendered":"\n<p> \u8f6f\u4ef6\u5f00\u53d1\u5e38\u5e38\u4f1a\u88ab\u8981\u6c42\u652f\u6301\u591a\u56fd\u8bed\u8a00\u3002\u800c\u4e14\u60f3\u8981\u8f6f\u4ef6\u6709\u66f4\u591a\u7684\u53d7\u4f17\uff0c\u505a\u597d\u672c\u5730\u5316\u65e0\u7591\u662f\u5fc5\u7136\u7684\u9009\u62e9\u3002\u5bf9\u4e8eWPF\u7a0b\u5e8f\u800c\u8a00\uff0c\u652f\u6301\u591a\u8bed\u8a00\u7684\u65b9\u5f0f\u6709\u5f88\u591a\u79cd\uff0c\u8fd9\u91cc\u4ecb\u7ecd\u4e00\u79cd\u6bd4\u8f83\u5e38\u89c1\u4e86\u65b9\u5f0f\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1\u3001 \u521b\u5efa\u8d44\u6e90\u8bcd\u5178\uff0c\u9996\u5148\u65b0\u5efa\u4e24\u4e2a\u8bcd\u5178\u6587\u4ef6en-us.xaml\u3001zh-cn.xaml <\/h3>\n\n\n\n<p> zh-cn.xaml code\uff1a <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;ResourceDictionary xmlns=\"http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\/presentation\"\n                    xmlns:x=\"http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\"\n                    xmlns:local=\"clr-namespace:GPIO_TOOL_WIN\"\n                    xmlns:s=\"clr-namespace:System;assembly=mscorlib\">\n    &lt;s:String x:Key=\"buttonTest1\">\u6d4b\u8bd5\u6309\u94ae1&lt;\/s:String>\n    &lt;s:String x:Key=\"buttonTest2\">\u6d4b\u8bd5\u6309\u94ae2&lt;\/s:String>\n    &lt;s:String x:Key=\"buttoncn\">\u4e2d\u6587&lt;\/s:String>\n    &lt;s:String x:Key=\"buttonen\">\u82f1\u6587&lt;\/s:String>\n&lt;\/ResourceDictionary><\/code><\/pre>\n\n\n\n<p> en-us.xaml code\uff1a <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;ResourceDictionary xmlns=\"http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\/presentation\"\n                    xmlns:x=\"http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\"\n                    xmlns:local=\"clr-namespace:TEST_TOOL_WIN\"\n                    xmlns:s=\"clr-namespace:System;assembly=mscorlib\">\n    &lt;s:String x:Key=\"buttonTest1\">Button TEST1&lt;\/s:String>\n    &lt;s:String x:Key=\"buttonTest2\">Button TEST2&lt;\/s:String>\n    &lt;s:String x:Key=\"buttoncn\">Chinese&lt;\/s:String>\n    &lt;s:String x:Key=\"buttonen\">English&lt;\/s:String>\n&lt;\/ResourceDictionary><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2\u3001 \u5c06\u4e24\u4e2a\u8d44\u6e90\u8bcd\u5178\u6dfb\u52a0\u5230App.xaml\u4e2d <\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;Application x:Class=\"GPIO_TOOL_WIN.App\"\n             xmlns=\"http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\/presentation\"\n             xmlns:x=\"http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\"\n             xmlns:local=\"clr-namespace:TEST_TOOL_WIN\"\n             StartupUri=\"MainWindow.xaml\">\n    &lt;Application.Resources>\n        &lt;ResourceDictionary>\n            &lt;ResourceDictionary.MergedDictionaries>\n                &lt;ResourceDictionary Source=\"Resources\\en-us.xaml\" \/>\n                &lt;ResourceDictionary Source=\"Resources\\zh-cn.xaml\" \/>\n            &lt;\/ResourceDictionary.MergedDictionaries>\n        &lt;\/ResourceDictionary>\n    &lt;\/Application.Resources>\n&lt;\/Application><\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">3\u3001 \u5728\u754c\u9762\u8bbe\u8ba1\u5668\u4e2d\u9700\u8981\u663e\u793a\u7684\u4f4d\u7f6e\u6dfb\u52a0\u52a8\u6001\u8d44\u6e90 <\/h2>\n\n\n\n<p>\u4f8b\u5982\uff1a<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;Window x:Class=\"GPIO_TOOL_WIN.MainWindow\"\n        xmlns=\"http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\/presentation\"\n        xmlns:x=\"http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\"\n        xmlns:d=\"http:\/\/schemas.microsoft.com\/expression\/blend\/2008\"\n        xmlns:mc=\"http:\/\/schemas.openxmlformats.org\/markup-compatibility\/2006\"\n        xmlns:local=\"clr-namespace:TEST_TOOL_WIN\"\n        mc:Ignorable=\"d\"\n        Title=\"WPF TEST\" Height=\"450\" Width=\"800\">\n    &lt;Grid>\n        &lt;Button x:Name=\"buttonTest1\" Content=\"{DynamicResource buttonTest1}\" HorizontalAlignment=\"Left\" Margin=\"20,20,0,0\" VerticalAlignment=\"Top\" Width=\"100\"\/>\n        &lt;Button x:Name=\"buttonTest2\" Content=\"{DynamicResource buttonTest2}\" HorizontalAlignment=\"Left\" Margin=\"20,50,0,0\" VerticalAlignment=\"Top\" Width=\"100\"\/>\n        &lt;Button x:Name=\"buttoncn\" Content=\"{DynamicResource buttoncn}\" HorizontalAlignment=\"Left\" Margin=\"20,150,0,0\" VerticalAlignment=\"Top\" Width=\"75\" Click=\"Buttoncn_Click\"\/>\n        &lt;Button x:Name=\"buttonen\" Content=\"{DynamicResource buttonen}\" HorizontalAlignment=\"Left\" Margin=\"120,150,0,0\" VerticalAlignment=\"Top\" Width=\"75\" Click=\"Buttonen_Click\"\/>\n    &lt;\/Grid>\n&lt;\/Window><\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4\u3001 \u5207\u6362\u8bed\u8a00\u4ee3\u7801\u5982\u4e0b\uff1a <\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>List&lt;ResourceDictionary> dictionaryList = new List&lt;ResourceDictionary>();\n            foreach (ResourceDictionary dictionary in Application.Current.Resources.MergedDictionaries)\n            {\n                dictionaryList.Add(dictionary);\n            }\n            string requestedCulture = @\"Resources\\en-us.xaml\";\/\/or zh-cn.xaml\n            ResourceDictionary resourceDictionary = dictionaryList.Find(d => d.Source.OriginalString.Equals(requestedCulture));\n            Application.Current.Resources.MergedDictionaries.Remove(resourceDictionary);\n            Application.Current.Resources.MergedDictionaries.Add(resourceDictionary);<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">5\u3001\u6d4b\u8bd5\u6548\u679c<\/h3>\n\n\n\n<div class=\"wp-block-image\"><figure class=\"aligncenter\"><img loading=\"lazy\" decoding=\"async\" width=\"455\" height=\"275\" src=\"http:\/\/iqotom.com\/wp-content\/uploads\/2019\/11\/wpf_resources_zh_en.gif\" alt=\"\" class=\"wp-image-1133\"\/><\/figure><\/div>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8f6f\u4ef6\u5f00\u53d1\u5e38\u5e38\u4f1a\u88ab\u8981\u6c42\u652f\u6301\u591a\u56fd\u8bed\u8a00\u3002\u800c\u4e14\u60f3\u8981\u8f6f\u4ef6\u6709\u66f4\u591a\u7684\u53d7\u4f17\uff0c\u505a\u597d\u672c\u5730\u5316\u65e0\u7591\u662f\u5fc5\u7136\u7684\u9009\u62e9\u3002\u5bf9\u4e8eWPF\u7a0b\u5e8f\u800c\u8a00\uff0c\u652f\u2026 <span class=\"read-more\"><a href=\"http:\/\/iqotom.com\/?p=1132\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":1136,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[56],"tags":[57,90],"_links":{"self":[{"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/posts\/1132"}],"collection":[{"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/iqotom.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1132"}],"version-history":[{"count":2,"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/posts\/1132\/revisions"}],"predecessor-version":[{"id":1135,"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/posts\/1132\/revisions\/1135"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/iqotom.com\/index.php?rest_route=\/wp\/v2\/media\/1136"}],"wp:attachment":[{"href":"http:\/\/iqotom.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1132"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/iqotom.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1132"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/iqotom.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1132"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}