Note that there are some explanatory texts on larger screens.

plurals
  1. POMVVM, XML, and Master/Detail Scenarios
    primarykey
    data
    text
    <p>I am working on my first MVVM project in C#, a conversion from a non MVVM project, and have questions around every corner. Although I can't share the exact data I'm using I have come up with a similar scenario that will help to address my questions.</p> <p>Here is the data:</p> <pre><code> &lt;Stock&gt; &lt;Container Store="Store1" Aisle="1" Shelf="2" Name="Box1"&gt; &lt;Item Name="GreenBeans"/&gt; &lt;Item Name="Carrots"/&gt; ... &lt;/Container&gt; &lt;Container Store="Store3" Aisle="4" Shelf="6" Name="Box2"&gt; &lt;Item Name="Pillow"/&gt; &lt;Item Name="Blanket"/&gt; ... &lt;/Container&gt; ... &lt;/Stock&gt; </code></pre> <p>There is potential to be thousands of containers each with 10-15 items. It is possible for any two of the locators (Store/Aisle/Shelf) to be equivalent, but not all three (i.e. one container can exist in a certain location Store -> Aisle -> Shelf). </p> <p>My current model clases are as below. These aren't the complete models, but this gives an idea of where I'm headed. It is possible, but not likely, that I will need to know all <code>&lt;Item\&gt;</code> at a particular Store or on a particular Aisle. With that said, is it imperative that I have those classes?</p> <pre><code>public class Store { public String StoreName; public Aisles StoreAisles; } public class Stores { ObservableCollection&lt;Store&gt; } public class Aisle { public int AisleNumber; public Shelfs AisleShelfs; } public class Aisles { ObservableCollection&lt;Aisle&gt; } public class Shelf { public int ShelfNumber; public Items ShelfItems; } public class Shelfs { ObservableCollection&lt;Shelf&gt; } public class Item { public string Name; } public class Items { ObservableCollection&lt;Item&gt; } </code></pre> <p>There will be three comboboxes (Stores, Aisles, and Shelfs) in a master/detail scenario. The data will be queried to tell me which store(s) are available, which aisle(s) at the store are being used, then which shelf(s) are in use on each aisle. Once <code>&lt;Container\&gt;</code> is established then the <code>&lt;Item(s)\&gt;</code> that are in that container will be bound to a user-control.</p> <p>At this point, I am unsure of how to handle the data. Before going the MVVM route I was gathering the string from each SelectedItem and using those as inputs into a XElement Linq query. This would return a <code>&lt;Container\&gt;</code> in which I would then query the <code>&lt;Item(s)\&gt;</code>.</p> <p>I want to take advantage of binding and avoid all the queries when I make changes to any of the comboboxes. How can I use binding to return the selected <code>&lt;Container\&gt;</code> to a property in the viewmodel?</p> <p>All help and suggestions are welcome!</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