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

  • SEARCH
  • Home
  • 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 8027781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T23:54:49+00:00 2026-06-04T23:54:49+00:00

I am new to WPF. I have a database table with 2 columns: Category,

  • 0

I am new to WPF.

I have a database table with 2 columns: Category, Type. Primary key combination is (Category, Type). Type is subordinate to Category, meaning 1 Category containing multiple Type.

Now, in my WPF UI, I have 2 comboBox controls. The first bind to distinct category list in the DB table. I have done it by binding the control to a DB view of distinct(Category). The second needs to show Type list belonging to the category currently selected in first control.

I did research but have no idea how to easily do it. I tried creating a stored procedure to select the wanted Type value list based on Category given, but don’t know how to pass the selected Category to the stored procedure in XAML. Must I use code rather than XAML to do it? What is your suggestion?

Thanks a lot

  • 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-06-04T23:54:51+00:00Added an answer on June 4, 2026 at 11:54 pm

    I would create an object to hold your categories that contain each type possible for that category. Something like…

    public class Category
    {
        public ObservableCollection<string> Types { get; set; }
    }
    

    Then when you initialize every Category, you can set which Types are allowed in…

    public class MyClass
    {
        public ObservableCollection<Category> Categories { get; set; }
        public MyClass()
        {
             InitializeComponent();
             ObservableCollection MyTypes = new ObservableCollection();
             MyTypes.Add("type1");
             MyTypes.Add("type2");
             MyTypes.Add("Type3");
             Categories.Add(new Category() { Types = MyTypes });
             //Probably a more elegant way to do this, but hard to say based on information given
    
             this.DataContext = this;
        }
    }
    

    Lastly you can bind the first combobox to the category list, and the second to the Types list of the selected item of the other combobox.

    <ComboBox Name="cboCategory" ItemsSource = "{Binding Categories}" />
    
    <ComboBox ItemsSource = "{Binding ElementName=cboCategory, Path=SelectedItem.Types}" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a WPF-application that is looking for new images in a database and
I'm new to WPF. I have a WPF Window with a bunch of Labels
I'm kind of new to WPF although I have some experience in Forms, and
I have a WPF sorting/binding issue. (Disclaimer: I am very new to WPF and
I am new to WPF and xaml and I have a problem with my
New to wpf and through a learning curve. I have a userControl with a
I am new to WPF. I have this code <Window x:Class=ElementBinding.MultipleBindings xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml Title=MultipleBindings
I am new to WPF. I have a ListBox that has its ItemSource set
I am new to WPF. I have a code which displays a UI window
I am new to wpf and i am working on first application i have

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.