{"id":543,"date":"2019-12-23T02:23:02","date_gmt":"2019-12-22T17:23:02","guid":{"rendered":"http:\/\/marius.main.jp\/software\/blog\/?p=543"},"modified":"2021-03-14T05:41:08","modified_gmt":"2021-03-13T20:41:08","slug":"post-543","status":"publish","type":"post","link":"https:\/\/todosoft.net\/blog\/?p=543","title":{"rendered":"ListView\u306e\u4e2d\u8eab\u306e\u5e45\u3092\u3044\u3063\u3071\u3044\u306b\u5e83\u3052\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=\"WpfApp15.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:WpfApp15\"\n        mc:Ignorable=\"d\"\n        Title=\"MainWindow\" Height=\"450\" Width=\"400\">\n    &lt;Grid>\n        &lt;ListView Margin=\"30\" ItemsSource=\"{Binding arrayString}\">\n            \n            &lt;ListView.ItemContainerStyle>\n                &lt;Style TargetType=\"ListViewItem\">\n                    &lt;Setter Property=\"HorizontalContentAlignment\" Value=\"Stretch\" \/>\n                &lt;\/Style>\n            &lt;\/ListView.ItemContainerStyle>\n\n            &lt;ListView.ItemTemplate>\n                &lt;DataTemplate>\n                    &lt;Button Height=\"50\" Content=\"{Binding}\"\/>\n                &lt;\/DataTemplate>\n            &lt;\/ListView.ItemTemplate>\n        &lt;\/ListView>\n    &lt;\/Grid>\n&lt;\/Window>\n<\/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.Windows;\nusing System.Collections.ObjectModel;\n\nnamespace WpfApp15\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 ObservableCollection&lt;string> arrayString { get; set; } = new ObservableCollection&lt;string>();\n\n        public MainWindow()\n        {\n            InitializeComponent();\n\n            for(int intCount = 0; intCount &lt; 10; intCount++)\n            {\n                arrayString.Add(intCount.ToString());\n            }\n\n            this.DataContext = this;\n        }\n    }\n}<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"386\" height=\"443\" src=\"http:\/\/marius.main.jp\/software\/blog\/wp-content\/uploads\/2019\/12\/WpfApp15.png\" alt=\"\" class=\"wp-image-544\" srcset=\"https:\/\/todosoft.net\/blog\/wp-content\/uploads\/2019\/12\/WpfApp15.png 386w, https:\/\/todosoft.net\/blog\/wp-content\/uploads\/2019\/12\/WpfApp15-261x300.png 261w\" sizes=\"auto, (max-width: 386px) 100vw, 386px\" \/><\/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":[48,75],"class_list":["post-543","post","type-post","status-publish","format-standard","hentry","category-c","category-wpf","category-15","tag-listview","tag-75"],"_links":{"self":[{"href":"https:\/\/todosoft.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/543","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=543"}],"version-history":[{"count":5,"href":"https:\/\/todosoft.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/543\/revisions"}],"predecessor-version":[{"id":780,"href":"https:\/\/todosoft.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/543\/revisions\/780"}],"wp:attachment":[{"href":"https:\/\/todosoft.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/todosoft.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/todosoft.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}