Note that there are some explanatory texts on larger screens.

plurals
  1. POMVVM View representation when using a list and multiple view model properties
    primarykey
    data
    text
    <p>In reference to <a href="https://stackoverflow.com/questions/16270351/assistance-required-with-delegates-example/16270867?noredirect=1#comment23358668_16270867">a previous question with an MVVM answer</a></p> <p>I'm trying to build on this, instead of simply using text in the listbox, I want to be able to insert a UserControl that displays 3 different properties of the Model (or do i need another ViewModel?).</p> <p>I could easily add the UserControl directly into the ListBox, but I'm pretty sure this wouldn't be congruent with the MVVM pattern.</p> <p>Just wondering if someone could help.</p> <p><strong>The UserControl Code</strong></p> <pre><code>public partial class ActionModule : UserControl { public ActionsViewModel ViewModel { get; set; } public ActionModule() { InitializeComponent(); } } </code></pre> <p><strong>The UserControl UI</strong></p> <pre><code>&lt;UserControl x:Class="DelegateAction.ActionModule" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:Ignorable="d" &gt; &lt;DockPanel&gt; &lt;DockPanel.Resources&gt; &lt;Style TargetType="TextBlock"&gt; &lt;Setter Property="TextAlignment" Value="Center"/&gt; &lt;Setter Property="Height" Value="24" /&gt; &lt;Setter Property="Padding" Value="3" /&gt; &lt;/Style&gt; &lt;/DockPanel.Resources&gt; &lt;TextBlock DockPanel.Dock="Top" MinWidth="150" Text="Title"/&gt; &lt;Button DockPanel.Dock="Bottom" Content="Action" MinWidth="150" /&gt; &lt;TextBlock DockPanel.Dock="Left" MinWidth="75" Text="Owner"/&gt; &lt;TextBlock DockPanel.Dock="Right" MinWidth="75" Text="Score" /&gt; &lt;/DockPanel&gt; </code></pre> <p></p> <p><strong>The Model for the UserControl</strong></p> <pre><code>public class ActionItem { public string Title { get; set; } public string Owner { get; set; } public short Score { get; set; } public Action Action { get; set; } } </code></pre> <p>In the ViewModel from the last example, we had these collections, do they stay as a collection of ActionItem's or does it need to be of ActionModule's?</p> <pre><code>public class ActionsViewModel : PropertyChangedBase { public ObservableCollection&lt;ActionItem&gt; AvailableActions { get; set; } public ObservableCollection&lt;ActionItem&gt; SelectedActions { get; set; } public ActionItem FocusedAction1 { get; set; } public ActionItem FocusedAction2 { get; set; } </code></pre> <p>Thanks for your help in advance :)</p>
    singulars
    1. This table or related slice is empty.
    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. 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