{"id":913,"date":"2021-09-20T20:42:12","date_gmt":"2021-09-20T12:42:12","guid":{"rendered":"http:\/\/www.wayln.com\/?p=913"},"modified":"2021-09-20T20:42:12","modified_gmt":"2021-09-20T12:42:12","slug":"%e8%b5%84%e6%ba%90%e5%ad%97%e5%85%b8","status":"publish","type":"post","link":"https:\/\/www.wayln.com\/?p=913","title":{"rendered":"\u8d44\u6e90\u5b57\u5178"},"content":{"rendered":"<div id=\"toc_container\" class=\"toc_transparent no_bullets\"><p class=\"toc_title\">Contents<\/p><ul class=\"toc_list\"><li><a href=\"#i\"><span class=\"toc_number toc_depth_1\">1<\/span> \u521b\u5efa\u8d44\u6e90\u5b57\u5178<\/a><\/li><li><a href=\"#i-2\"><span class=\"toc_number toc_depth_1\">2<\/span> \u4f7f\u7528\u8d44\u6e90\u5b57\u5178<\/a><\/li><li><a href=\"#i-3\"><span class=\"toc_number toc_depth_1\">3<\/span> \u5728\u7a0b\u5e8f\u96c6\u4e4b\u95f4\u5171\u4eab\u8d44\u6e90<\/a><\/li><\/ul><\/div>\n<p>\u5982\u679c\u5e0c\u671b\u5728\u591a\u4e2a\u9879\u76ee\u4e4b\u95f4\u5171\u4eab\u8d44\u6e90\uff0c\u53ef\u521b\u5efa\u8d44\u6e90\u5b57\u5178\uff0c\u8d44\u6e90\u5b57\u5178\u53ea\u662fXAML\u6587\u6863\uff0c\u9664\u4e86\u5b58\u50a8\u5e0c\u671b\u4f7f\u7528\u7684\u8d44\u6e90\u5916\uff0c\u4e0d\u4f5c\u5176\u4ed6\u4efb\u4f55\u4e8b\u60c5<\/p>\n<h1><span id=\"i\">\u521b\u5efa\u8d44\u6e90\u5b57\u5178<\/span><\/h1>\n<pre data-language=XML><code class=\"language-markup line-numbers\">&lt;ResourceDictionary&gt;\n      &lt;ImageBrush x:Key=\"TileBrush\" TileMode=\"Tile\" Viewport=\"0 0 32 32\" ViewportUnits=\"Absolute\" ImageSource=\"jiya.png\" Opacity=\"0.3\"&gt;&lt;\/ImageBrush&gt;\n&lt;\/ResourceDictionary&gt;\n<\/code><\/pre>\n<h1><span id=\"i-2\">\u4f7f\u7528\u8d44\u6e90\u5b57\u5178<\/span><\/h1>\n<pre><code class=\"language-XML line-numbers\">&lt;Application.Resources&gt;\n    &lt;ResourceDictionary&gt;\n        &lt;ResourceDictionary.MergedDictionaries&gt;\n            &lt;ResourceDictionary Source=\"AppBrushes.xaml\"\/&gt;\n            &lt;ResourceDictionary Source=\"WizardBrushes.xaml\"\/&gt;\n        &lt;\/ResourceDictionary.MergedDictionaries&gt;\n    &lt;\/ResourceDictionary&gt;\n&lt;\/Application.Resources&gt;\n<\/code><\/pre>\n<p>\u4e0d\u5141\u8bb8\u5408\u5e76\u4f7f\u7528\u76f8\u540c\u8d44\u6e90\u540d\u79f0\u7684\u5b57\u5178<br \/>\n\u4f7f\u7528\u8d44\u6e90\u5b57\u5178\u7684\u4e00\u4e2a\u539f\u56e0\u662f\u4e3a\u4e86\u5b9a\u4e49\u4e00\u4e2a\u6216\u591a\u4e2a\u53ef\u91cd\u7528\u7684\u5e94\u7528\u7a0b\u5e8f\u201c\u76ae\u80a4\u201d\u3002\u53e6\u4e00\u4e2a\u539f\u56e0\u662f\u4e3a\u4e86\u5b58\u50a8\u9700\u8981\u88ab\u672c\u5730\u5316\u7684\u5185\u5bb9\u3002<\/p>\n<h1><span id=\"i-3\">\u5728\u7a0b\u5e8f\u96c6\u4e4b\u95f4\u5171\u4eab\u8d44\u6e90<\/span><\/h1>\n<p>\u5c06\u8d44\u6e90\u5b57\u5178\u7f16\u8bd1\u5230\u5355\u72ec\u7684\u7c7b\u5e93\u7a0b\u5e8f\u4e2d\uff0c\u5e76\u5206\u53d1\u7ec4\u4ef6\u3002<br \/>\n\u63d0\u53d6\u8d44\u6e90\u5e76\u5728\u5e94\u7528\u7a0b\u5e8f\u4e2d\u4f7f\u7528\u8d44\u6e90\u6709\u4e24\u79cd\u65b9\u6cd5\uff1a<br \/>\n1. \u4f7f\u7528\u4ee3\u7801\u521b\u5efa\u5408\u9002\u7684ResourceDictionary\u5bf9\u8c61<br \/>\n\u4f8b\u5982\uff0c\u5982\u679c\u7c7b\u5e93\u7a0b\u5e8f\u96c6\u4e2d\u6709\u540d\u4e3aReusableDictionary.xaml\u7684\u8d44\u6e90\u5b57\u5178\uff0c\u90a3\u4e48\u53ef\u4f7f\u7528\u4e0b\u9762\u7684\u4ee3\u7801\u624b\u52a8\u521b\u5efa\u8be5\u8d44\u6e90\u5b57\u5178\uff1a<\/p>\n<pre><code class=\"language-CSharp line-numbers\">ResourceDictionary resourceDictionary=new ResourceDictionary();\nresourceDictionary.Source=new Uri(\"ResourceLibrary;component\/ResableDictionary.xaml\",UriKind.Relative);\n<\/code><\/pre>\n<p>\u4e00\u6bb5\u4ece\u9ec4\u5efa\u4e86ResourceDictionary\u5bf9\u8c61\uff0c\u5c31\u53ef\u4ee5\u4ece\u96c6\u5408\u4e2d\u624b\u52a8\u68c0\u7d22\u6240\u9700\u8981\u7684\u8d44\u6e90\u4e86\uff1a<\/p>\n<pre><code class=\"language-CSharp line-numbers\">cmd.Background=(Brush)resourceDictionary[\"TileBrush\"];\n<\/code><\/pre>\n<ol start=\"2\">\n<li>\u5982\u679c\u4e0d\u60f3\u7f16\u5199\u4efb\u4f55\u4ee3\u7801\uff0c\u53ef\u4ee5\u4f7f\u7528ComponentResourceKey\u6807\u8bb0\u6269\u5c55\u3002<br \/>\n\u4f7f\u7528ComponetnResourceKey\u4e3a\u8d44\u6e90\u521b\u5efa\u952e\u540d\u3002\u901a\u8fc7\u6267\u884c\u8fd9\u4e00\u6b65\uff0c\u544a\u77e5WPF\u60a8\u51c6\u5907\u5728\u7a0b\u5e8f\u96c6\u4e4b\u95f4\u5171\u4eab\u8d44\u6e90\u3002<br \/>\n\u4e3a\u4e86\u8ba9\u8fd9\u79cd\u6280\u5de7\u751f\u6548\uff0c\u5fc5\u987b\u5c06\u8d44\u6e90\u5b57\u5178\u653e\u7f6e\u5230generic.xaml\u6587\u4ef6\u4e2d\uff0c\u5e76\u4e14\u5fc5\u987b\u5c06\u8be5\u6587\u4ef6\u653e\u5230\u5e94\u7528\u7a0b\u5e8f\u6587\u4ef6\u5939\u7684Themes\u5b50\u6587\u4ef6\u5939\u4e2d\u3002generic.xaml\u6587\u4ef6\u4e2d\u7684\u8d44\u6e90\u88ab\u8ba4\u4e3a\u662f\u9ed8\u8ba4\u4e3b\u9898\u7684\u4e00\u90e8\u5206\uff0c\u5e76\u4e14\u4ed6\u4eec\u603b\u662f\u53ef\u7528\u7684\u3002<br \/>\n\u4e3a\u5b58\u50a8\u5728ResourceLibrary\u7a0b\u5e8f\u96c6\u4e2d\u5e0c\u671b\u5171\u4eab\u7684\u8d44\u6e90\u521b\u5efa\u952e\u540d\u3002\u5f53\u4f7f\u7528ComponentResourceKey\u65f6\uff0c\u9700\u8981\u63d0\u4f9b\u4e24\u90e8\u5206\u4fe1\u606f\uff1a\u7c7b\u5e93\u7a0b\u5e8f\u96c6\u4e2d\u7c7b\u7684\u5f15\u7528\u548c\u63cf\u8ff0\u6027\u7684\u8d44\u6e90ID\u3002<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Contents1 \u521b\u5efa\u8d44\u6e90\u5b57\u51782 \u4f7f\u7528\u8d44\u6e90\u5b57\u51783 \u5728\u7a0b\u5e8f\u96c6\u4e4b\u95f4\u5171\u4eab\u8d44\u6e90 \u5982\u679c\u5e0c\u671b\u5728\u591a\u4e2a\u9879\u76ee\u4e4b\u95f4\u5171\u4eab\u8d44\u6e90\uff0c\u53ef\u521b [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,35,36,2],"tags":[],"class_list":["post-913","post","type-post","status-publish","format-standard","hentry","category-c","category-wpf","category-2"],"_links":{"self":[{"href":"https:\/\/www.wayln.com\/index.php?rest_route=\/wp\/v2\/posts\/913","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wayln.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wayln.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wayln.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wayln.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=913"}],"version-history":[{"count":1,"href":"https:\/\/www.wayln.com\/index.php?rest_route=\/wp\/v2\/posts\/913\/revisions"}],"predecessor-version":[{"id":914,"href":"https:\/\/www.wayln.com\/index.php?rest_route=\/wp\/v2\/posts\/913\/revisions\/914"}],"wp:attachment":[{"href":"https:\/\/www.wayln.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=913"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wayln.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=913"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wayln.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=913"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}