Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6682735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:44:26+00:00 2026-05-26T04:44:26+00:00

I am working on my first MVVM project in C#, a conversion from a

  • 0

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.

Here is the data:

   <Stock>
      <Container Store="Store1"
                 Aisle="1"
                 Shelf="2"
                 Name="Box1">
         <Item Name="GreenBeans"/>
         <Item Name="Carrots"/>
         ...
      </Container>
      <Container Store="Store3"
                 Aisle="4"
                 Shelf="6"
                 Name="Box2">
         <Item Name="Pillow"/>
         <Item Name="Blanket"/>
         ...
      </Container>
      ...
   </Stock>

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).

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 <Item\> at a particular Store or on a particular Aisle. With that said, is it imperative that I have those classes?

public class Store
{
   public String StoreName;
   public Aisles StoreAisles; 
}

public class Stores
{
   ObservableCollection<Store>
}

public class Aisle
{
   public int AisleNumber;
   public Shelfs AisleShelfs;
}

public class Aisles
{
   ObservableCollection<Aisle>
}

public class Shelf
{
  public int ShelfNumber;
  public Items ShelfItems;
}

public class Shelfs
{
   ObservableCollection<Shelf>
}

public class Item
{
   public string Name;
}

public class Items
{
   ObservableCollection<Item>
}

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 <Container\> is established then the <Item(s)\> that are in that container will be bound to a user-control.

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 <Container\> in which I would then query the <Item(s)\>.

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 <Container\> to a property in the viewmodel?

All help and suggestions are welcome!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:44:26+00:00Added an answer on May 26, 2026 at 4:44 am

    even if you use queries in the back you still could use binding (and why not) – you just have to fire the proper INotifyPropertyChanges as a result of one ComboBox-Changing (and with it the bound values in your ViewModel) – like this:

    public string SelectedStoreName
    {
       get { return _storeName; }
       set {
          if (!Equals(value, _storeName))
          {
             _storeName = value;
             _currentStore = FindStore(value);
             OnPropertyChanged("SelectedStoreName"); // invokes INotifyPropertyChanged
             OnPropertyChanged("AvaiableAisles");
          }
       }
    }
    
    public IEnumerable<Aisles> AvaiableAisles
    {
        get { return _currentStore.StoreAisles.ToArray(); }
    }
    
    /* same with the rest of your chain */
    

    Please Note a few things:

    • SelectedStoreName should be bound to your Store-Combobox if you don’t like the string part change it (but I see no need)
    • AvaiableAisles should be bound to the Itemsource of your Aisles-Combobox – you will need a ItemTemplate or the right .ToString() overload in Aisles to show the content you like. If you don’t like this approach change AvaiableAisles with a .Select(...) before the .ToArray() to select a string and change the signature into IEnumerable<string> AvaiableAisles
    • I did not mind any error handling for example using _currentStore
    • you have to Implemet INotifyPropertyChanged if you don’t have allready
    • you have to implement the FindStore – this is where the query-part is
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on my first true WPF MVVM pattern application. Currently I have a
I'm working on an MVVM project, so I have folders in my project like
I have a Silverlight project I'm converting to MVVM. It's my first time using
First some background: I'm working on an application and I'm trying to follow MVVM
I have pretty much finished my first working Symbian application, but in my hastened
Working on my first Rails project, I used Ryan Bates' Nifty-Generators to create the
I'm working for the first time with Forms Authentication, I'm using an example from
I'm working on my first object oriented bit of python and I have the
I'm working on a first symfony project, i am using the sfWidgetFormTextareaTinyMCE widget for
I'm, currently working my first project in .NET 4.0 and it requires several thousand

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.