Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Caliburn.Micro has baked in conventions supporting <code>ItemsControl</code> (e.g. ComboBox or ListBox) based controls which make the required xaml in you View minimal.</p> <p>First you have the standard convention where a controls content will be bound to a ViewModel property with the same name as the control. In the case of <code>ItemsControl</code> the controls content property is <code>ItemsControl.ItemsSource</code>. And the second convention you get out of the box with Caliburn.Micro is that an attempt will be made to bind <code>ItemsControl.SelectedItem</code> to a ViewModel property which has the singularized name of the control, with either "Active", "Selected" or "Current" prepended (see <code>ConventionManager</code> in the Caliburn.Micro source).</p> <p>This in mind you can achieve what you want with the following in your View:</p> <pre><code>&lt;ComboBox x:Name="Strings"&gt;&lt;/ComboBox&gt; </code></pre> <p>and in your ViewModel:</p> <pre><code>public BindableCollection&lt;string&gt; Strings { get { // silly example of the collection to bind to return new BindableCollection&lt;string&gt;( new string[]{ "one", "two", "three"}); } } private string _selectedString; public string SelectedString { get { return _selectedString; } set { _selectedString= value; NotifyOfPropertyChange(() =&gt; SelectedString); // and do anything else required on selection changed } } </code></pre> <p>The first convention picks up the control name ("Strings") and binds <code>ComboBox.ItemsSource</code> to the ViewModel property <code>Strings</code>. The second convention first singularizes "Strings" to "String" and prepends "Selected" to get the property "SelectedString" to bind <code>ComboBox.SelectedItem</code> to.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload