{"id":205,"date":"2022-08-31T23:12:22","date_gmt":"2022-08-31T15:12:22","guid":{"rendered":"https:\/\/www.jinhaihan.top\/WordPress\/?p=205"},"modified":"2022-08-31T23:12:25","modified_gmt":"2022-08-31T15:12:25","slug":"wpf%e4%b8%ad%e7%9a%84%e5%a4%9a%e8%af%ad%e8%a8%80%e6%94%af%e6%8c%81_%e5%8a%a8%e6%80%81%e5%88%87%e6%8d%a2%e8%af%ad%e8%a8%80","status":"publish","type":"post","link":"https:\/\/www.jinhaihan.top\/WordPress\/wpf%e4%b8%ad%e7%9a%84%e5%a4%9a%e8%af%ad%e8%a8%80%e6%94%af%e6%8c%81_%e5%8a%a8%e6%80%81%e5%88%87%e6%8d%a2%e8%af%ad%e8%a8%80\/","title":{"rendered":"wpf\u4e2d\u7684\u591a\u8bed\u8a00\u652f\u6301_\u52a8\u6001\u5207\u6362\u8bed\u8a00"},"content":{"rendered":"\n<div class=\"wp-block-jetpack-markdown\"><p>\u4e3b\u6d41\u65b9\u6cd5\u53c2\u8003\u535a\u5ba2\uff1a(\u867d\u7136\u8001\u4e86\u70b9\u4f46\u662f\u6709\u7528)<\/p>\n<blockquote>\n<p><a href=\"https:\/\/www.cnblogs.com\/horan\/archive\/2012\/04\/20\/wpf-multilanguage.html#ViaResourceDictionary\" target=\"_blank\" rel=\"noopener\">WPF\u5e94\u7528\u7a0b\u5e8f\u652f\u6301\u591a\u56fd\u8bed\u8a00\u89e3\u51b3\u65b9\u6848<\/a><\/p>\n<\/blockquote>\n<p>\u4f46\u662f\u9ed8\u8ba4\u7684\u65b9\u6848\u91cc\u8bd5\u7528\u9759\u6001\u8d44\u6e90\u4e0d\u80fd\u52a8\u6001\u5207\u6362\u8bed\u8a00\uff0c\u4ee5\u4e0b\u662f\u52a8\u6001\u5207\u6362\u8bed\u8a00\u7684\u65b9\u6cd5\uff0c\u53ef\u4ee5\u5728\u8fd0\u884c\u65f6\u5207\u6362\u8bed\u8a00\u3002<\/p>\n<h1>\u521d\u6b65\u914d\u7f6e<\/h1>\n<p>\u5728\u6587\u4ef6\u5939\u4e2d\u65b0\u5efa\u8d44\u6e90\u6587\u4ef6\uff0c\u6bd4\u5982<code>Resources\/zh.xaml<\/code>\u548c<code>Resources\/en.xaml<\/code><\/p>\n<p>\u6587\u4ef6\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<pre><code>&lt;ResourceDictionary xmlns=&quot;http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\/presentation&quot;\n                    xmlns:x=&quot;http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml&quot;\n                    xmlns:system=&quot;clr-namespace:System;assembly=mscorlib&quot;\n                    xmlns:local=&quot;clr-namespace:WPFMultiLanguage.Resources.Language&quot;&gt;\n    &lt;system:String x:Key=&quot;Testing&quot;&gt;Testing...&lt;\/system:String&gt;\n&lt;\/ResourceDictionary&gt;\n<\/code><\/pre>\n<p>\u5728app.xaml\u4e2d\u6dfb\u52a0\u6b64\u6587\u4ef6\u4e3a\u8d44\u6e90\uff0c<strong>\u6dfb\u52a0\u4e00\u4e2a\u5c31\u884c\u4e86<\/strong>\uff0c\u4f5c\u4e3a\u9ed8\u8ba4\u8bed\u8a00\u3002\u6700\u7ec8<code>app.xaml<\/code>\u5dee\u4e0d\u591a\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n<pre><code>&lt;Application\n    x:Class=&quot;DeviceInfoSyncClient.App&quot;\n    xmlns=&quot;http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml\/presentation&quot;\n    xmlns:x=&quot;http:\/\/schemas.microsoft.com\/winfx\/2006\/xaml&quot;\n    xmlns:ui=&quot;http:\/\/schemas.lepo.co\/wpfui\/2022\/xaml&quot;\n    DispatcherUnhandledException=&quot;OnDispatcherUnhandledException&quot;\n    Exit=&quot;OnExit&quot;\n    Startup=&quot;OnStartup&quot;&gt;\n    &lt;Application.Resources&gt;\n        &lt;ResourceDictionary&gt;\n            &lt;ResourceDictionary.MergedDictionaries&gt;\n                &lt;!--Default Language File--&gt;\n                &lt;ResourceDictionary Source=&quot;\/DeviceInfoSyncClient;component\/Resources\/en_us.xaml&quot;\/&gt;\n                -------\u5176\u4ed6\u7684\u8d44\u6e90\u6587\u4ef6\n            &lt;\/ResourceDictionary.MergedDictionaries&gt;\n        &lt;\/ResourceDictionary&gt;\n    &lt;\/Application.Resources&gt;\n&lt;\/Application&gt;\n\n<\/code><\/pre>\n<p>\u5728\u7a0b\u5e8f\u4e2d\u4f7f\u7528\u65f6\uff0c\u9700\u8981\u5728xaml\u4e2d\u83b7\u53d6\u7684\u8bdd\uff0c\u9700\u8981\u4f7f\u7528<code>DynamicResource<\/code>\u4ee5\u5e94\u5bf9\u52a8\u6001\u4fee\u6539\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre><code>&lt;Grid&gt;\n        &lt;StackPanel&gt;\n            &lt;TextBlock Text=&quot;{DynamicResource Greeting}&quot;\/&gt;\n\n            &lt;Button Content=&quot;{DynamicResource Language}&quot; Width=&quot;100&quot; Height=&quot;35&quot; Click=&quot;SwitchButton_Click&quot;\/&gt;\n        &lt;\/StackPanel&gt;\n    &lt;\/Grid&gt;\n<\/code><\/pre>\n<p>\u5728cs\u6587\u4ef6\u4e2d\u52a8\u6001\u83b7\u53d6\u7684\u8bdd\uff0c\u5c31\u76f4\u63a5<\/p>\n<pre><code> (string)Application.Current.FindResource(&quot;Testing&quot;)\n<\/code><\/pre>\n<h1>\u52a8\u6001\u5207\u6362<\/h1>\n<p>\u56e0\u4e3a\u5df2\u7ecf\u5c06\u4e00\u4e2a\u6587\u4ef6\u4f5c\u4e3a\u8d44\u6e90\u5b57\u5178\u4e86\uff0c\u5176\u4ed6\u7684\u8bed\u8a00\u7684\u8d44\u6e90\u6587\u4ef6\u6ca1\u6709\u7528\u5230\uff0c\u8fd9\u91cc\u9700\u8981\u52a8\u6001\u66ff\u6362\u4e00\u4e0b\uff1a<\/p>\n<pre><code> public static void ChangeLanguage(string newLang)\n{\n    ResourceDictionary dict = new ResourceDictionary();\n    \/\/\u4e0b\u9762\u6362\u6210\u4f60\u60f3\u8981\u7684\u8d44\u6e90\u5b57\u5178\n    dict.Source = new Uri(@&quot;Resources\\zh_cn.xaml&quot;, UriKind.Relative);\n    Application.Current.Resources.MergedDictionaries[0] = dict;\n}\n<\/code><\/pre>\n<\/div>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":206,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[21,7],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/08\/pexels-photo-6045344.jpeg?fit=1880%2C1245&ssl=1","jetpack-related-posts":[{"id":225,"url":"https:\/\/www.jinhaihan.top\/WordPress\/wpf-databinding%e7%9a%84%e5%87%a0%e7%a7%8d%e6%96%b9%e5%bc%8f\/","url_meta":{"origin":205,"position":0},"title":"# WPF Databinding\u7684\u51e0\u79cd\u65b9\u5f0f","author":"Kim","date":"2022\u5e7412\u670829\u65e5","format":false,"excerpt":"WPF Databinding\u7684\u51e0\u79cd\u65b9\u5f0f \u6709\u65f6\u5019\u4f1a\u548cUWP\u3001\u5176\u4ed6\u8bed\u8a00\u7684\u7ed1\u5b9a\u5f04\u6df7\uff0c\u8fd9\u91cc\u505a\u4e00\u4e0b\u5907\u4efd\u8bb0\u5f55 \u2026","rel":"","context":"\u5728\u201cWPF\u201d\u4e2d","block_context":{"text":"WPF","link":"https:\/\/www.jinhaihan.top\/WordPress\/category\/bolg\/wpf\/"},"img":{"alt_text":"gray and brown mountain","src":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/12\/pexels-photo-417173.jpeg?fit=1200%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/12\/pexels-photo-417173.jpeg?fit=1200%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/12\/pexels-photo-417173.jpeg?fit=1200%2C800&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/12\/pexels-photo-417173.jpeg?fit=1200%2C800&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":228,"url":"https:\/\/www.jinhaihan.top\/WordPress\/databinding%e7%bb%91%e5%ae%9a%e4%b8%8d%e5%90%8c%e4%b8%8a%e4%b8%8b%e6%96%87%e7%9a%84%e5%b1%9e%e6%80%a7\/","url_meta":{"origin":205,"position":1},"title":"Databinding\u7ed1\u5b9a\u4e0d\u540c\u4e0a\u4e0b\u6587\u7684\u5c5e\u6027","author":"Kim","date":"2022\u5e7412\u670830\u65e5","format":false,"excerpt":"\u7ed1\u5b9a\u67d0\u7236\u7ea7\u7684\u5c5e\u6027 \u5047\u8bbe\u573a\u666f\uff1a \u5b58\u5728\u4e00\u4e2a\u5df2\u7ecf\u8bbe\u7f6e\u4e86Item source\u7684ListView\uff0cListV\u2026","rel":"","context":"\u5728\u201cWPF\u201d\u4e2d","block_context":{"text":"WPF","link":"https:\/\/www.jinhaihan.top\/WordPress\/category\/bolg\/wpf\/"},"img":{"alt_text":"The Rhine\u2013Meuse\u2013Scheldt river delta in the Netherlands","src":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/12\/49830289321_83c90a1dd4_b.jpg?fit=1024%2C683&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/12\/49830289321_83c90a1dd4_b.jpg?fit=1024%2C683&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/12\/49830289321_83c90a1dd4_b.jpg?fit=1024%2C683&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":197,"url":"https:\/\/www.jinhaihan.top\/WordPress\/197\/","url_meta":{"origin":205,"position":2},"title":"gradle\u7684java\u9879\u76eeLombok\u62a5\u9519\u7684\u89e3\u51b3\u65b9\u5f0f","author":"Kim","date":"2022\u5e747\u670830\u65e5","format":false,"excerpt":"\u4e00. \u68c0\u67e5\u9879\u76ee\u914d\u7f6e \u5982\u5176\u4ed6\u535a\u5ba2\u6240\u8bf4\uff0c\u4f18\u5148\u68c0\u67e5\u9879\u76ee\u914d\u7f6e 1. \u68c0\u67e5\u9879\u76ee\u4f9d\u8d56\u662f\u5426\u6b63\u5e38\uff0c\u5305\u62ec\u6ce8\u89e3\u5904\u7406\u5668 \u5728\u2026","rel":"","context":"\u5728\u201cJava\u201d\u4e2d","block_context":{"text":"Java","link":"https:\/\/www.jinhaihan.top\/WordPress\/category\/bolg\/java\/"},"img":{"alt_text":"grey white clouds","src":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/07\/clouds-cloudporn-weather-lookup-158163.jpeg?fit=1200%2C675&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/07\/clouds-cloudporn-weather-lookup-158163.jpeg?fit=1200%2C675&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/07\/clouds-cloudporn-weather-lookup-158163.jpeg?fit=1200%2C675&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/07\/clouds-cloudporn-weather-lookup-158163.jpeg?fit=1200%2C675&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":235,"url":"https:\/\/www.jinhaihan.top\/WordPress\/%e5%9c%a8gin%e6%a1%86%e6%9e%b6%e4%b8%ad%e8%8e%b7%e5%8f%96%e5%a4%96%e9%83%a8%e8%af%b7%e6%b1%82%e4%b8%adget%e5%92%8cpost%e7%9a%84%e5%8f%82%e6%95%b0\/","url_meta":{"origin":205,"position":3},"title":"\u5728Gin\u6846\u67b6\u4e2d\u83b7\u53d6\u5916\u90e8\u8bf7\u6c42\u4e2dGet\u548cPost\u7684\u53c2\u6570","author":"Kim","date":"2023\u5e741\u670831\u65e5","format":false,"excerpt":"\u9996\u5148\u5047\u8bbe\u5df2\u7ecf\u642d\u5efa\u597d\u6574\u4e2a\u670d\u52a1\uff0c\u5e76\u521b\u5efa\u4e86\u51e0\u4e2aAPI\u7528\u4e8e\u6d4b\u8bd5\u3002 \u5728Get\u8bf7\u6c42\u4e2d\uff0c\u5047\u8bbe\u7531\u4ee5\u4e0b\u51fd\u6570\u5904\u7406\uff0c\u5219\u83b7\u53d6\u2026","rel":"","context":"\u5728\u201cGolang\u201d\u4e2d","block_context":{"text":"Golang","link":"https:\/\/www.jinhaihan.top\/WordPress\/category\/bolg\/golang\/"},"img":{"alt_text":"Dynamic Earth - Ocean Currents","src":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2023\/01\/7402441936_5c99447ca0_b.jpg?fit=1024%2C576&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2023\/01\/7402441936_5c99447ca0_b.jpg?fit=1024%2C576&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2023\/01\/7402441936_5c99447ca0_b.jpg?fit=1024%2C576&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":72,"url":"https:\/\/www.jinhaihan.top\/WordPress\/android%e7%94%b3%e8%af%b7usb%e6%9d%83%e9%99%90%e6%97%a0%e6%95%88%e7%9a%84%e4%b8%80%e7%a7%8d%e5%8f%af%e8%83%bd\/","url_meta":{"origin":205,"position":4},"title":"Android\u7533\u8bf7USB\u6743\u9650\u65e0\u6548\u7684\u4e00\u79cd\u53ef\u80fd","author":"Kim","date":"2021\u5e747\u67084\u65e5","format":false,"excerpt":"USB\u6743\u9650\u53ef\u4ee5\u5f39\u51fa\u7533\u8bf7\u6846\u7684\u5fc5\u8981\u6761\u4ef6\uff1a \u5728\u5bf9\u5e94\u7684\u6e05\u5355\u6587\u4ef6\u4e2d\u7533\u8bf7\u5fc5\u8981\u6743\u9650\u3002 \u52a8\u6001\u6216\u8005\u9759\u6001\u7533\u8bf7\u3002 \u5176\u4e2d\u7b2c\u4e8c\u2026","rel":"","context":"\u5728\u201cAndroid\u201d\u4e2d","block_context":{"text":"Android","link":"https:\/\/www.jinhaihan.top\/WordPress\/category\/bolg\/android\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2021\/10\/456536-scaled.jpg?fit=1200%2C675&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2021\/10\/456536-scaled.jpg?fit=1200%2C675&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2021\/10\/456536-scaled.jpg?fit=1200%2C675&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2021\/10\/456536-scaled.jpg?fit=1200%2C675&ssl=1&resize=1050%2C600 3x"},"classes":[]},{"id":202,"url":"https:\/\/www.jinhaihan.top\/WordPress\/maple\/","url_meta":{"origin":205,"position":5},"title":"Maple","author":"Kim","date":"2022\u5e748\u670826\u65e5","format":false,"excerpt":"\u4ee5\u4e0b\u5185\u5bb9\u6458\u81eaMaple\u4ed3\u5e93\u7684Readme Maple Series V5 \u6ce8\u610f\u4e8b\u9879 \u56e0\u4e3a\u6211\u6ca1\u6709 ma\u2026","rel":"","context":"\u5728\u201c\u535a\u5ba2\u201d\u4e2d","block_context":{"text":"\u535a\u5ba2","link":"https:\/\/www.jinhaihan.top\/WordPress\/category\/bolg\/"},"img":{"alt_text":"down angle photography of red clouds and blue sky","src":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/08\/pexels-photo-844297.jpeg?fit=1200%2C800&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/08\/pexels-photo-844297.jpeg?fit=1200%2C800&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/08\/pexels-photo-844297.jpeg?fit=1200%2C800&ssl=1&resize=700%2C400 2x, https:\/\/i0.wp.com\/www.jinhaihan.top\/WordPress\/wp-content\/uploads\/2022\/08\/pexels-photo-844297.jpeg?fit=1200%2C800&ssl=1&resize=1050%2C600 3x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/posts\/205"}],"collection":[{"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/comments?post=205"}],"version-history":[{"count":1,"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/posts\/205\/revisions"}],"predecessor-version":[{"id":207,"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/posts\/205\/revisions\/207"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/media\/206"}],"wp:attachment":[{"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/media?parent=205"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/categories?post=205"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.jinhaihan.top\/WordPress\/wp-json\/wp\/v2\/tags?post=205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}