{"id":1460,"date":"2014-02-18T21:31:03","date_gmt":"2014-02-18T21:31:03","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=1460"},"modified":"2014-02-18T21:31:03","modified_gmt":"2014-02-18T21:31:03","slug":"binding-to-a-listbox-and-selected-item-using-caliburn-micro","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/binding-to-a-listbox-and-selected-item-using-caliburn-micro\/","title":{"rendered":"Binding to a listbox and selected item using Caliburn Micro"},"content":{"rendered":"<p>This will work with a listbox or combo box.<\/p>\n<p>So, using Caliburn Micro we use convention based naming for the ItemsSource as follows<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;ListBox x:Name=&quot;Employees&quot; \/&gt;\r\n<\/pre>\n<p>But as you see there&#8217;s nothing for SelectedItem, instead it is taken that the property name in the view model for the selected item will be <em>SelectedEmployee<\/em>, i.e.<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\npublic class EmployeesViewModel : PropertyChangedBase\r\n{\r\n   private EmployeeViewModel selected;\r\n\r\n   public ObservableCollection&lt;EmployeeViewModel&gt; Employees { get; private set; }\r\n\r\n   public EmployeeViewModel SelectedEmployee\r\n   {\r\n      get { return selected; }\r\n      set\r\n      {\r\n         if (selected != value)\r\n         {\r\n            selected = value;\r\n            NotifyOfPropertyChange();\r\n         }\r\n      }\r\n   }\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This will work with a listbox or combo box. So, using Caliburn Micro we use convention based naming for the ItemsSource as follows &lt;ListBox x:Name=&quot;Employees&quot; \/&gt; But as you see there&#8217;s nothing for SelectedItem, instead it is taken that the property name in the view model for the selected item will be SelectedEmployee, i.e. public [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[61],"tags":[],"class_list":["post-1460","post","type-post","status-publish","format-standard","hentry","category-caliburn-micro"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/1460","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=1460"}],"version-history":[{"count":2,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/1460\/revisions"}],"predecessor-version":[{"id":1468,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/1460\/revisions\/1468"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=1460"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=1460"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=1460"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}