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 973479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:17:08+00:00 2026-05-16T03:17:08+00:00

This question ties to my previous question but is more specific. Say I have

  • 0

This question ties to my previous question but is more specific. Say I have two ComboBoxes, one populated with product names, the other empty. When a product is chosen, I want the second ComboBox to be filled with data related to that product. I have XML like the following:

<Products>
    <Product name="MyProduct1">
        <Components>
            <Component name="MyComponent1"/>
            <Component name="MyComponent2"/>
            ...more Component nodes...
        </Components>
    </Product>
    ...more Product nodes...
</Products>

What I was hoping is that I could somehow set the XPath on the Component ComboBox such that it gets all the Components/Component nodes from the Product node whose @name attribute is equal to the currently selected value in the Product ComboBox. Is this possible? How would I do it? Here’s what I have in my XAML so far:

<ComboBox Height="23" HorizontalAlignment="Left" Margin="138,116,0,0"
          Name="cbo_product" VerticalAlignment="Top" Width="120"
          ItemsSource="{Binding Source={StaticResource productsXml}}"
          DisplayMemberPath="@name"/>
<ComboBox Height="23" HorizontalAlignment="Left" Margin="138,151,0,0"
            Name="cbo_component" VerticalAlignment="Top" Width="201"
            DisplayMemberPath="@name">
    <ComboBox.ItemsSource>
        <!-- Currently gets all Component nodes--want it to get only those
             associated with the selected Product -->
        <Binding Source="{StaticResource productsXml}"
                 XPath="Components/Component"/>
    </ComboBox.ItemsSource>
</ComboBox>

The Product ComboBox is filled with product names like MyProduct1, so that part is fine. It’s the dependent Component ComboBox I need help with.

  • 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-16T03:17:09+00:00Added an answer on May 16, 2026 at 3:17 am

    After Googling around for examples of XPath expressions in WPF, I found this article that gave me my solution in a round-about way. His example was more complicated than mine, so I didn’t have to go creating XML converter classes. I just needed the following XAML for my dependent Component ComboBox:

    <ComboBox Height="23" HorizontalAlignment="Left" Margin="138,151,0,0"
              Name="cbo_component" VerticalAlignment="Top" Width="201"
              DataContext="{Binding ElementName=cbo_product, Path=SelectedItem}"
              ItemsSource="{Binding XPath=Components/Component}"
              DisplayMemberPath="@name"/>
    

    Here, cbo_product is the Name of my Product ComboBox.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question is specific to Erlang, but may have general implications to other IO
This question suddenly popped into my head... I have a table that ties two
This question is related with one of my earlier questions.. Previous Post In there
I have a query based on the answer to this question: Handling ties when
This question was posted on StackApps , but the issue may be more a
This question seems to have been asked a lot but all were trying to
This question is specific to the MSVC compiler (specifically 2008), but I'm interested in
This question is related to this question , but not quite the same. Say
This question might be naive as I'm new to ColdFusion programming. I have a
This question is similar to this one How do I add options to a

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.