{"id":996,"date":"2010-07-07T15:12:39","date_gmt":"2010-07-07T06:12:39","guid":{"rendered":"http:\/\/www.moonmile.net\/blog\/archives\/996"},"modified":"2010-07-08T22:40:59","modified_gmt":"2010-07-08T13:40:59","slug":"wpf%e3%81%aelistboxselecteditem%e3%81%ae%e6%8c%99%e5%8b%95%e3%81%8c%e3%81%8a%e3%81%8b%e3%81%97%e3%81%84","status":"publish","type":"post","link":"http:\/\/www.moonmile.net\/blog\/archives\/996","title":{"rendered":"WPF\u306eListBox.SelectedItem\u306e\u6319\u52d5\u304c\u304a\u304b\u3057\u3044"},"content":{"rendered":"<p>\u6700\u8fd1\u3001\u30c4\u30fc\u30eb\u3092\u4f5c\u308b\u3068\u304d\u306b\u3001Windows Forms \u3067\u306f\u306a\u304f\u3066\u3001WPF \u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u7406\u7531\u306e\u7b2c\u4e00\u306f\u3001UI \u304c\u7dba\u9e97\u306b\u4f5c\u308c\u308b\u304b\u3089\u3001\u306a\u3093\u3067\u3059\u304c\u3001\u901a\u5e38\u306e\u30d5\u30a9\u30fc\u30e0\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u308b\u306e\u3068\u52dd\u624b\u304c\u9055\u3046 or \u52d5\u304d\u304c\u304a\u304b\u3057\u3044\u3001\u3068\u308d\u304c\u591a\u3005\u3042\u3063\u3066\u3001\u3061\u3087\u3063\u3068\u907f\u3051\u308b\u3079\u304d\u7406\u7531\u3082\u3061\u3089\u307b\u3089\u3002<\/p>\n<p>\u4eca\u3001\u4f7f\u3063\u3066\u3044\u308b\u306e\u306f WPF \u306e\u30ea\u30b9\u30c8\u30dc\u30c3\u30af\u30b9\u306a\u306e\u3067\u3059\u304c\u3001\u3069\u3046\u3084\u3089\u3001<\/p>\n<ol>\n<li>\u30ea\u30b9\u30c8\u30dc\u30c3\u30af\u30b9\u306e\u9805\u76ee\u3092 Remove \u30e1\u30bd\u30c3\u30c9\u3067\u524a\u9664\u3059\u308b\u3002<\/li>\n<li>\u30ab\u30fc\u30bd\u30eb\u3092\u8a2d\u5b9a\u3059\u308b\u305f\u3081\u306b SelectedIndex \u3067\u9078\u629e\u3055\u305b\u308b\u3002<\/li>\n<li>\u3053\u306e\u5f8c\u3001\u30ab\u30fc\u30bd\u30eb\u30ad\u30fc\u306e\u4e0a\u77e2\u5370\u3084\u4e0b\u77e2\u5370\u30ad\u30fc\u3092\u62bc\u3059\u3068\u3001\u5148\u982d\u306b\u30ab\u30fc\u30bd\u30eb\u304c\u79fb\u52d5\u3057\u3066\u3057\u307e\u3046\u3002<\/li>\n<\/ol>\n<p>\u3068\u3044\u3046\u73fe\u8c61\u3067\u3059\u3002<\/p>\n<p>\u524a\u9664\u3059\u308b\u5834\u5408\u306f\u3001\u6b21\u306e\u30b3\u30fc\u30c9\u306e\u3088\u3046\u306b\u3001DELETE\u30ad\u30fc\u3092\u62bc\u3057\u305f\u3068\u304d\u306b\u3001\u9078\u629e\u884c\u3092\u524a\u9664\u3057\u307e\u3059\u3002<\/p>\n<blockquote style=\"MARGIN-RIGHT: 0px\" dir=\"ltr\"><p>private void listBox1_KeyDown(object sender, KeyEventArgs e)<br \/>\n{<br \/>\n\u00a0\u00a0\u00a0 if (e.Key == Key.Delete)<br \/>\n\u00a0\u00a0\u00a0 {<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 int index = listBox1.SelectedIndex;<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 listBox1.Items.RemoveAt(index);<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 index&#8211;;<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 if (index &lt; 0) index = 0;<br \/>\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 listBox1.SelectedIndex = index;<br \/>\n\u00a0\u00a0\u00a0 }<br \/>\n}<\/p><\/blockquote>\n<p>\u3053\u3046\u3059\u308b\u3068\u3067\u3059\u306d\u3001\u305b\u3063\u304b\u304f SelectedIndex \u3092\u8a2d\u5b9a\u3057\u3066\u3044\u306e\u306b\u3001\u4e0a\u4e0b\u306e\u77e2\u5370\u30ad\u30fc\u3067\u5148\u982d\u306e\u884c\u306b\u30b8\u30e3\u30f3\u30d7\u3057\u3066\u3057\u307e\u3046\u3093\u3067\u3059\u3088\u306d\u3002\u3002\u3002\u3069\u3046\u3082\u3001SelectedIndex \u306e\u5024\u304c\u3001\u5185\u90e8\u3067\u53cd\u6620\u3055\u308c\u3066\u3044\u306a\u3044\u6c17\u304c\u3057\u307e\u3059\u3002<\/p>\n<p># \u4f3c\u305f\u3088\u3046\u306a\u73fe\u8c61\u3092\u3001Siverlight \u306e ListBox \u3067\u7d4c\u9a13\u3057\u305f\u3088\u3046\u306a\u899a\u3048\u304c\u3042\u308b\u3093\u3060\u3051\u3069&#8230;\u3061\u3087\u3063\u3068\u3001\u89e3\u6c7a\u7b56\u3092\u601d\u3044\u51fa\u305b\u305a\u3002<br \/>\n# XAML \u3067\u4fdd\u6301\u3057\u3066\u3044\u308b\u30d7\u30ed\u30d1\u30c6\u30a3\u306b\u53cd\u6620\u3055\u308c\u3066\u3044\u306a\u3044\u96f0\u56f2\u6c17\u306a\u3093\u3067\u3059\u306d\u3002<\/p>\n<p>\u89e3\u6c7a\u3057\u305f\u3089\u8ffd\u8a18\u3092\u66f8\u304d\u307e\u3059\u3002<\/p>\n<p>\u8ffd\u8a18 2010\/07\/08<br \/>\n\u3078\u3063\u307d\u3053\u72ec\u81eaSilverlight\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u304c\u3001\u305d\u3093\u306a\u52d5\u304d\u3092\u3057\u3066\u3044\u305f\u306a\u3041\u3068\u601d\u3044\u51fa\u3057\u305f\u3002<br \/>\nMVVM \u304c\u5206\u304b\u3063\u3066\u3044\u306a\u304f\u3066\u3001\u30b3\u30f3\u30c8\u30ed\u30fc\u30eb\u81ea\u8eab\u3092INotifyChanged\u3092\u3057\u3066\u3044\u305f\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3002<br \/>\n\u307e\u3055\u304b\u3001\u305d\u3093\u306a\u3053\u3068\u3042\u308b\u307e\u3044\u306a\uff1eMS<\/p>\n<p>\u8ffd\u8a18 2010\/07\/08<br \/>\n\u3069\u3046\u3084\u3089\u3001\u30d0\u30b0\u3063\u307d\u3044\u3002<\/p>\n<p>\u5168\u304f\u540c\u3058\u30b3\u30fc\u30c9\u3092Windows \u30d5\u30a9\u30fc\u30e0\u3067\u52d5\u304b\u3059\u3068\u6b63\u5e38\u306b\u52d5\u304f\u306e\u3067\u3001Microsoft\u3055\u3093\u306b\u30d5\u30a3\u30fc\u30c9\u30d0\u30c3\u30af\u3057\u307e\u3057\u305f\u3002<br \/>\n<a href=\"http:\/\/connect.microsoft.com\/VisualStudioJapan\/feedback\/details\/573823\/wpf-listbox-selectedindex\">http:\/\/connect.microsoft.com\/VisualStudioJapan\/feedback\/details\/573823\/wpf-listbox-selectedindex<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u3001\u30c4\u30fc\u30eb\u3092\u4f5c\u308b\u3068\u304d\u306b\u3001Windows Forms \u3067\u306f\u306a\u304f\u3066\u3001WPF \u3092\u4f7f\u3063\u3066\u3044\u307e\u3059\u3002 \u7406\u7531\u306e\u7b2c\u4e00\u306f\u3001UI \u304c\u7dba\u9e97\u306b\u4f5c\u308c\u308b\u304b\u3089\u3001\u306a\u3093\u3067\u3059\u304c\u3001\u901a\u5e38\u306e\u30d5\u30a9\u30fc\u30e0\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u3092\u4f5c\u308b\u306e\u3068\u52dd\u624b\u304c\u9055\u3046 or \u52d5\u304d\u304c\u304a\u304b\u3057\u3044\u3001\u3068 &hellip; <a href=\"http:\/\/www.moonmile.net\/blog\/archives\/996\">\u7d9a\u304d\u3092\u8aad\u3080 <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3],"tags":[],"class_list":["post-996","post","type-post","status-publish","format-standard","hentry","category-dev"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/996","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/comments?post=996"}],"version-history":[{"count":5,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/996\/revisions"}],"predecessor-version":[{"id":998,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/posts\/996\/revisions\/998"}],"wp:attachment":[{"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/media?parent=996"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/categories?post=996"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.moonmile.net\/blog\/wp-json\/wp\/v2\/tags?post=996"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}