Note that there are some explanatory texts on larger screens.

plurals
  1. POMVVM - Summary/Detail
    primarykey
    data
    text
    <p>So I'm trying to wrap my head around MVVM and I'm finding that I have more questions than answers. The tutorials don't go far enough for me when it comes to the next step...</p> <p>Basically I want a list of items and then a way to get the detail of each item.</p> <p>Below is the examples that I've found online and they work great for displaying the list, but I need to know how I can use my VM to get the detail of this item.</p> <pre><code>private IList&lt;item&gt; m_items; private IList&lt;item&gt; m_Item; private IList&lt;item&gt; getItemDetail(Int32 iId) { var myItem = from i in items where i.iId == iId select i; m_Item = new List&lt;item&gt;(); foreach (var item in myItem) { m_Item.Add(item); } return m_Item; } public myViewModel() { m_items = new List&lt;item&gt; { new item(1, "test,), new item(2, "test2"), new item(3, "test1") }; m_Item = new List&lt;item&gt;(); m_Item = getItemDetail(iId); } </code></pre> <p><strong>Update:</strong></p> <p>I updated my View Model code above. I think what I've done is I have added another List where when the user navigates to a detail page the view model gets called with the specific ID which then populates the detail List. I probably don't need a list here but I wanted to try to keep it consistent with the main page code.</p> <p>In my detail page I'm setting up the VM this way:</p> <pre><code> itemViewModel VM = new itemViewModel((Int32)navigationParameter); DataContext = VM; </code></pre> <p>When I break on the VM variable I see my 2 lists. However, my binding doesn't work on the XAML. If I need to post some sample XAML let me know. I can do that but I'm hoping there is something I'm missing here. </p> <p>I'm trying to learn MVVM and I want to do things right. So instead of continuing down a wrong path I would really like to know the "right" way of doing things. So if you see errors, please let me know.</p> <p>Thanks!</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. 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