{"id":939,"date":"2021-09-24T21:53:41","date_gmt":"2021-09-24T13:53:41","guid":{"rendered":"http:\/\/www.wayln.com\/?p=939"},"modified":"2021-09-24T21:53:41","modified_gmt":"2021-09-24T13:53:41","slug":"%e6%8e%a7%e4%bb%b6%e6%a8%a1%e6%9d%bf","status":"publish","type":"post","link":"https:\/\/www.wayln.com\/?p=939","title":{"rendered":"\u63a7\u4ef6\u6a21\u677f"},"content":{"rendered":"<h1>\u7406\u89e3\u903b\u8f91\u6811\u548c\u53ef\u89c6\u5316\u6811<\/h1>\n<p>\u6dfb\u52a0\u7684\u5143\u7d20\u5206\u7c7b\u79f0\u4e3a\u903b\u8f91\u6811\u3002<br \/>\n\u53ef\u89c6\u5316\u6811\u662f\u903b\u8f91\u6811\u7684\u6269\u5c55\u7248\u672c\u3002\u5b83\u5c06\u5143\u7d20\u5206\u6210\u66f4\u5c0f\u7684\u90e8\u5206\u3002\u6362\u53e5\u8bdd\u8bf4\uff0c\u5b83\u5e76\u4e0d\u67e5\u770b\u88ab\u7cbe\u795e\u5c01\u88c5\u5230\u4e00\u8d77\u7684\u9ed1\u8272\u65b9\u6846\uff0c\u5982\u6309\u94ae\uff0c\u800c\u662f\u67e5\u770b\u6309\u94ae\u7684\u53ef\u89c6\u5316\u5143\u7d20\u2014\u2014\u4f7f\u6309\u94ae\u5177\u6709\u5f15\u7528\u5317\u4eac\u7279\u6027\u7684\u8fb9\u6846\uff08\u7531ButtonChrome\u7c7b\u8868\u793a\uff09\u3001\u5185\u90e8\u7684\u5bb9\u5668\uff08ContentPresenter\u5bf9\u8c61\uff09\u4ee5\u53ca\u5b58\u50a8\u6309\u94ae\u6587\u672c\u7684\u5757\uff08\u7531\u5927\u5bb6\u719f\u6089\u7684TextBlock\u8868\u793a<\/p>\n<p><a class=\"wp-editor-md-post-content-link\" href=\"http:\/\/www.wayln.com\/wp-content\/uploads\/2021\/09\/wp_editor_md_8a4df807751321174be67cb0d0205f56.jpg\"><img decoding=\"async\" src=\"http:\/\/www.wayln.com\/wp-content\/uploads\/2021\/09\/wp_editor_md_8a4df807751321174be67cb0d0205f56.jpg\" alt=\"\" \/><\/a><\/p>\n<p>\u53ef\u91c7\u7528\u591a\u79cd\u65b9\u6cd5\u5c06\u4e00\u9897\u903b\u8f91\u6811\u6269\u5c55\u6210\u4e00\u9897\u53ef\u89c6\u5316\u6811\uff0c\u8ba4\u8bc6\u5230\u8fd9\u4e00\u70b9\u662f\u5f88\u91cd\u8981\u7684\uff0c\u4f7f\u7528\u7684\u6837\u5f0f\u548c\u8bbe\u7f6e\u7684\u5c5e\u6027\u7b49\u7ea7\u7ec6\u8282\u3002\u4f8b\u5982\uff0c\u5728\u524d\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u6309\u94ae\u5305\u542b\u4e86\u6587\u672c\u5185\u5bb9\uff0c\u56e0\u6b64\u4f1a\u81ea\u52a8\u521b\u5efa\u5d4c\u5957\u7684TextBlock\u5143\u7d20\u3002<br \/>\n\u901a\u8fc7\u53ef\u89c6\u5316\u6811\u53ef\u4ee5\u5b8c\u6210\u4e00\u4e0b\u4e24\u9879\u975e\u5e38\u6709\u7528\u7684\u5de5\u4f5c\uff1a<br \/>\n&#8211; \u53ef\u4f7f\u7528\u6837\u5f0f\u6539\u53d8\u53ef\u89c6\u5316\u6811\u4e2d\u7684\u5143\u7d20\u3002\u53ef\u4f7f\u7528Style.TargetType\u5c5e\u6027\u9009\u62e9\u5e0c\u671b\u4fee\u6539\u7684\u7279\u5b9a\u5143\u7d20\u3002\u751a\u81f3\u5f53\u7a7a\u95f4\u5c5e\u6027\u53d1\u751f\u53d8\u5316\u65f6\uff0c\u53ef\u4f7f\u7528\u89e6\u53d1\u5668\u81ea\u52a8\u5b8c\u6210\u66f4\u6539\u3002\u4e0d\u8fc7\uff0c\u67d0\u4e9b\u7279\u5b9a\u7684\u7ec6\u8282\u5f88\u96be\u751a\u81f3\u65e0\u6cd5\u4fee\u6539\u3002<br \/>\n&#8211; \u53ef\u4e3a\u7a7a\u95f4\u521b\u5efa\u65b0\u7684\u6a21\u677f\uff0c\u5bf9\u4e8e\u8fd9\u79cd\u60c5\u51b5\uff0c\u63a7\u4ef6\u6a21\u677f\u5c06\u88ab\u7528\u4e8e\u6309\u671f\u671b\u7684\u65b9\u5f0f\u6784\u5efa\u53ef\u89c6\u5316\u6811\u3002<br \/>\nWPF\u63d0\u4f9b\u4e86\u7528\u4e8e\u6d4f\u89c8\u903b\u8f91\u6811\u548c\u53ef\u89c6\u5316\u7684\u4e24\u4e2a\u96f7\uff1aSystem.Windows\u3002LogicalTreeHelper\u548cSystem.Windows.Media.VisualTreeHelper<\/p>\n<p>LogicalTreeHelper\u7c7b\u7684\u65b9\u6cd5\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>\u540d\u79f0<\/th>\n<th>\u8bf4\u660e<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>FindLogicalNode()<\/td>\n<td>\u6839\u636e\u540d\u79f0\u67e5\u627e\u7279\u5b9a\u5143\u7d20\uff0c\u4ece\u6307\u5b9a\u7684\u5143\u7d20\u5f00\u59cb\u5e76\u5411\u4e0b\u67e5\u627e\u903b\u8f91\u6811<\/td>\n<\/tr>\n<tr>\n<td>BringIntoView()<\/td>\n<td>\u5982\u679c\u5143\u7d20\u5728\u53ef\u6eda\u52a8\u7684\u5bb9\u5668\u5185\uff0c\u5e76\u4e14\u5f53\u524d\u4e0d\u53ef\u89c1\uff0c\u5c31\u5c06\u5143\u7d20\u6df7\u52a8\u5230\u89c6\u56fe\u4e2d\u3002FrameworkElement.BringIntoView()\u65b9\u6cd5\u6267\u884c\u76f8\u540c\u7684\u5de5\u4f5c<\/td>\n<\/tr>\n<tr>\n<td>GetParent()<\/td>\n<td>\u83b7\u53d6\u6307\u5b9a\u5143\u7d20\u7684\u7236\u5143\u7d20<\/td>\n<\/tr>\n<tr>\n<td>GetChildren()<\/td>\n<td>\u83b7\u53d6\u6307\u5b9a\u5143\u7d20\u7684\u5b50\u5143\u7d20<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u9664\u4e86\u4e13\u95e8\u7528\u6765\u6267\u884c\u4f4e\u7ea7\u7ed8\u56fe\u64cd\u4f5c\u7684\u4e00\u4e9b\u65b9\u6cd5\u5916\uff08\u4f8b\u5982\uff0c\u53ef\u7528\u4e8e\u660e\u653f\u7b56\u662f\u548c\u8fb9\u754c\u68c0\u67e5\u7684\u65b9\u6cd5\uff09\uff0cViwualTreeHelper\u7c7b\u63d0\u4f9b\u7684\u65b9\u6cd5\u548cLogicalTreeHelper\u7c7b\u63d0\u4f9b\u7684\u65b9\u6cd5\u7c7b\u4f3c\u3002<br \/>\nVisualTreeHelper\u7c7b\u8fd8\u63d0\u4f9b\u4e86\u4e00\u79cd\u7814\u7a76\u5e94\u7528\u7a0b\u5e8f\u4e2d\u53ef\u89c6\u5316\u6811\u7684\u53c8\u53bb\u65b9\u6cd5\u3002\u4f7f\u7528GetChild()\u65b9\u6cd5\uff0c\u53ef\u4ee5\u904d\u5386\u4efb\u610f\u7a97\u53e3\u7684\u53ef\u89c6\u5316\u6811\uff0c \u5e76\u4e14\u4e3a\u4e86\u8fdb\u884c\u5206\u6790\u53ef\u4ee5\u5c06\u4ed6\u4eec\u663e\u793a\u51fa\u6765\u3002\u8fd9\u662f\u4e00\u4e2a\u975e\u5e38\u597d\u7684\u5b66\u4e60\u5de5\u5177\uff0c\u53ea\u9700\u8981\u4f7f\u7528\u4e00\u4e9b\u9012\u5f52\u7684\u4ee3\u7801\u5c31\u53ef\u4ee5\u5b9e\u73b0\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7406\u89e3\u903b\u8f91\u6811\u548c\u53ef\u89c6\u5316\u6811 \u6dfb\u52a0\u7684\u5143\u7d20\u5206\u7c7b\u79f0\u4e3a\u903b\u8f91\u6811\u3002 \u53ef\u89c6\u5316\u6811\u662f\u903b\u8f91\u6811\u7684\u6269\u5c55\u7248\u672c\u3002\u5b83\u5c06\u5143\u7d20\u5206\u6210\u66f4\u5c0f\u7684\u90e8\u5206\u3002\u6362\u53e5\u8bdd\u8bf4 [&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-939","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\/939","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=939"}],"version-history":[{"count":1,"href":"https:\/\/www.wayln.com\/index.php?rest_route=\/wp\/v2\/posts\/939\/revisions"}],"predecessor-version":[{"id":940,"href":"https:\/\/www.wayln.com\/index.php?rest_route=\/wp\/v2\/posts\/939\/revisions\/940"}],"wp:attachment":[{"href":"https:\/\/www.wayln.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=939"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wayln.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=939"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wayln.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=939"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}