{"id":586,"date":"2020-01-12T21:27:23","date_gmt":"2020-01-12T12:27:23","guid":{"rendered":"http:\/\/marius.main.jp\/software\/blog\/?p=586"},"modified":"2021-03-14T05:40:11","modified_gmt":"2021-03-13T20:40:11","slug":"post-586","status":"publish","type":"post","link":"https:\/\/todosoft.net\/blog\/?p=586","title":{"rendered":"Window\u306e\u5b50\u8981\u7d20\u3092\u518d\u5e30\u691c\u7d22\u3059\u308b"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">MainWindow.xaml<\/h2>\n\n\n\n<pre class=\"wp-block-luxe-blocks-syntaxhighlighter line-numbers language-csharp\"><code class=\"language-csharp\">&lt;Window x:Class=\"WpfApp24.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:WpfApp24\"\n        mc:Ignorable=\"d\"\n        Title=\"MainWindow\" Height=\"242\" Width=\"409\">\n    &lt;Grid>\n        &lt;TextBox HorizontalAlignment=\"Left\" Height=\"30\" Margin=\"65,10,0,0\" TextWrapping=\"Wrap\" Text=\"TextBox\" VerticalAlignment=\"Top\" Width=\"90\"\/>\n        &lt;Grid HorizontalAlignment=\"Left\" Height=\"125\" Margin=\"10,60,0,0\" VerticalAlignment=\"Top\" Width=\"365\" Background=\"#FF66EC49\">\n            &lt;Grid HorizontalAlignment=\"Left\" Height=\"60\" Margin=\"10,55,0,0\" VerticalAlignment=\"Top\" Width=\"150\" Background=\"#FFEA7878\">\n                &lt;TextBox HorizontalAlignment=\"Left\" Height=\"35\" Margin=\"10,10,0,0\" TextWrapping=\"Wrap\" Text=\"TextBox\" VerticalAlignment=\"Top\" Width=\"105\"\/>\n            &lt;\/Grid>\n            &lt;TextBox HorizontalAlignment=\"Left\" Height=\"35\" Margin=\"55,15,0,0\" TextWrapping=\"Wrap\" Text=\"TextBox\" VerticalAlignment=\"Top\" Width=\"105\"\/>\n            &lt;Grid HorizontalAlignment=\"Left\" Height=\"60\" Margin=\"190,55,0,0\" VerticalAlignment=\"Top\" Width=\"150\" Background=\"#FF7670F7\">\n                &lt;TextBox HorizontalAlignment=\"Left\" Height=\"35\" Margin=\"10,10,0,0\" TextWrapping=\"Wrap\" Text=\"TextBox\" VerticalAlignment=\"Top\" Width=\"105\"\/>\n            &lt;\/Grid>\n        &lt;\/Grid>\n\n    &lt;\/Grid>\n&lt;\/Window><\/code><\/pre>\n\n\n\n<!--more-->\n\n\n\n<h2 class=\"wp-block-heading\">MainWindow.xaml.cs<\/h2>\n\n\n\n<pre class=\"wp-block-luxe-blocks-syntaxhighlighter line-numbers language-csharp\"><code class=\"language-csharp\">using System;\nusing System.Windows;\nusing System.Windows.Controls;\n\nnamespace WpfApp24\n{\n    \/\/\/ &lt;summary>\n    \/\/\/ MainWindow.xaml \u306e\u76f8\u4e92\u4f5c\u7528\u30ed\u30b8\u30c3\u30af\n    \/\/\/ &lt;\/summary>\n    public partial class MainWindow : Window\n    {\n        public MainWindow()\n        {\n            InitializeComponent();\n\n            SetChildren(this, t => {\n                if (t is TextBox)\n                    ((TextBox)t).Text = DateTime.Now.ToString(\"yyyy\/MM\/dd HH:mm:ss\");\n            });\n        }\n\n        \/\/\/ &lt;summary>\n        \/\/\/ \u8981\u7d20\u306b\u30a2\u30af\u30b7\u30e7\u30f3\u3092\u9069\u7528 \u53ca\u3073 \u5b50\u8981\u7d20\u306e\u30ea\u30b9\u30c8\u30a2\u30c3\u30d7\n        \/\/\/ &lt;\/summary>\n        \/\/\/ &lt;param name=\"targetObject\">&lt;\/param>\n        \/\/\/ &lt;param name=\"action\">&lt;\/param>\n        private void SetChildren(DependencyObject targetObject, Action&lt;DependencyObject> action)\n        {\n            action(targetObject);\n\n            foreach (object objChild in LogicalTreeHelper.GetChildren(targetObject))\n            {\n                if (objChild is DependencyObject)\n                    SetChildren((DependencyObject)objChild, action);\n            }\n        }\n    }\n}<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"395\" height=\"235\" src=\"http:\/\/marius.main.jp\/software\/blog\/wp-content\/uploads\/2020\/01\/0d40a5e4a645fc6b96e767d64ac0878e.png\" alt=\"\" class=\"wp-image-588\" srcset=\"https:\/\/todosoft.net\/blog\/wp-content\/uploads\/2020\/01\/0d40a5e4a645fc6b96e767d64ac0878e.png 395w, https:\/\/todosoft.net\/blog\/wp-content\/uploads\/2020\/01\/0d40a5e4a645fc6b96e767d64ac0878e-300x178.png 300w\" sizes=\"auto, (max-width: 395px) 100vw, 395px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>MainWindow.xaml<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[19,20,15],"tags":[69,68,56],"class_list":["post-586","post","type-post","status-publish","format-standard","hentry","category-c","category-wpf","category-15","tag-69","tag-68","tag-56"],"_links":{"self":[{"href":"https:\/\/todosoft.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/586","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/todosoft.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/todosoft.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/todosoft.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/todosoft.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=586"}],"version-history":[{"count":6,"href":"https:\/\/todosoft.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/586\/revisions"}],"predecessor-version":[{"id":777,"href":"https:\/\/todosoft.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/586\/revisions\/777"}],"wp:attachment":[{"href":"https:\/\/todosoft.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=586"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/todosoft.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=586"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/todosoft.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=586"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}