Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to bind a list of child objects in Silverlight MVVM
    primarykey
    data
    text
    <p>In Silverlight, MVVM I have to create a property window, but I have just a <code>List&lt;AProperty&gt;</code> object, where <code>AProperty</code> is an abstract class with some child classes.</p> <p>I want to bind it to a Silverlight control (but to which one?), with some conditions:</p> <ol> <li>some child-properties must be shown as a textbox, some as a checkbox, and some as a combobox. It comes from the dynamic type.</li> <li>the AProperty class has a <code>PropertyGroup</code> and a <code>Name</code> field. The order must be alphabetic (<code>PropertyGroup &gt; Name</code>)</li> </ol> <p>Any idea or working example?</p> <p>My code:</p> <pre><code> public abstract class AProperty { private String _Name; private String _Caption; private String _PropertyGroup; public String Name { get { return _Name; } set { _Name = value; } } public String Caption { get { return _Caption; } set { _Caption = value; } } public String PropertyGroup { get { return _PropertyGroup; } set { _PropertyGroup = value; } } } List&lt;AProperty&gt; Properties; </code></pre> <p>And the xaml:</p> <pre><code>&lt;ListBox ItemsSource="{Binding ... Properties ...}"&gt; &lt;!-- Here order the items --&gt; &lt;ListBox.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;StackPanel Orientation="Horizontal"&gt; &lt;TextBlock Width="250" Text="{Binding Path=Caption}" /&gt; &lt;!-- And here need I a textbox, or a checkbox, or a combobox anyway --&gt; &lt;/StackPanel&gt; &lt;/DataTemplate&gt; &lt;/ListBox.ItemTemplate&gt; &lt;/ListBox&gt; </code></pre> <p>I've found value converters just for a control attribute, not for a whole stackpanel content.</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.
 

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