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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:41:49+00:00 2026-05-26T05:41:49+00:00

I have been working through a very small-scale WPF project in order to familiarize

  • 0

I have been working through a very small-scale WPF project in order to familiarize myself with it while I read Nathan’s book. I am attempting to do declarative binding on a single window with multiple tables from the same dataset. The schema (names have been changed to protect the innocent) is: tblMany2–tblOne–tblMany1

XAML is below, but in short:

  • I set the datacontext in the windows _loaded handler. I have tried both to the dataset and to the table which is the primary table conceptually (tblMany1).
  • I set the ItemSource on a combo box to tblMany1.
  • I set the ItemSource on a second combo box to the foreign key data relation (originally it was a tbo, but I’ve been working for a while).
  • The idea is to control the second combo box (and other controls) by changing the first.
  • The result so far is a blank entry in the second combobox with a debug output saying cannot find the property of whichever object I’ve set the ItemsSource to.

XAML:

<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace;system;assembly=mscorlib"
mc:Ignorable="d"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:my="clr-namespace:MyProject"
xmlns:dx="clr-namespace:System.Diagnostics;assembly=WindowsBase" 
    Height="500"
    Width="700"
    d:DesignHeight="350" d:DesignWidth="525" SizeToContent="WidthAndHeight">

<Window.Resources>
    <!--Data-->


    <!--Styles-->
    <Style x:Key="buttonStyle">
        <Setter Property="Button.Width" Value="85" />
        <Setter Property="Button.Height" Value="30" />
    </Style>
    <Style x:Key="chkImageStyle" TargetType="Image">
        <Setter Property="Image.Height" Value="25" />
        <Setter Property="Image.Width" Value="30" />
        <Setter Property="Image.Margin" Value="100,30,0,0" />
        <Setter Property="Image.Stretch" Value="Fill" />
        <Setter Property="Image.VerticalAlignment" Value="Top" />
        <Setter Property="Grid.Column" Value="1" />
        <Setter Property="Image.Source" Value="checkmark.jpg" />
        <Setter Property="Image.Visibility" Value="hidden" />
    </Style>

    <!--Data Tempaltes-->
    <DataTemplate x:Key="tblMany1Date">
        <TextBlock Text="{Binding Path=tblMany1Date, StringFormat=d,dx:PresentationTraceSources.TraceLevel=High}" />
    </DataTemplate>

    <DataTemplate x:Key="tblOneLink">
        <TextBlock HorizontalAlignment="Center">
            <Hyperlink NavigateUri="{Binding Path=tblOne.Link}">
                <Run Text="{Binding Path=tblOne.Name}" />
            </Hyperlink>
        </TextBlock>
    </DataTemplate>

</Window.Resources>

<Viewbox Stretch="Uniform" Height="500" Width="750">
    <!-- Main Dockpanel-->
    <DockPanel Name="DockPanel1">

        <!-- NavPane -->
        <StackPanel Height="315" Background ="LightBlue" DockPanel.Dock="Left" Name="StackPanel1" Width="135">
            <Button Margin="5" Content="New" Name="btnNewOne" Style="{StaticResource buttonStyle}"/>
            <Label Margin="0" Content="ManyDate:" Name="lblDate" />

            <!--Primary Control-->
            <ComboBox Margin ="0" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding Path=tblMany1}"
                  ItemTemplate="{StaticResource tblMany1Date}" Height="23" Name="cboDate" Width="120"
          ForceCursor="False" AllowDrop="False" />

            <TextBlock Margin="-5" Visibility="Hidden"/>

            <Label Margin="0" Content="OneName:" Name="lblOneName" />

            <ComboBox Margin="0" ItemsSource="{Binding FK_tblMany1_tblOne}"
                ItemTemplate="{StaticResource tblOneLink}" Name="cboOne" />

        </StackPanel>
    </DockPanel>
</Viewbox>

  • 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-26T05:41:50+00:00Added an answer on May 26, 2026 at 5:41 am

    As far as I see, you bind two comboboxes to the same data context.
    But if I understand you correctly, you want the second combobox to display the items related with the selected item of the first combobox.

    You can achieve this either in this way (change the datacontext):

    <ComboBox DataContext="{Binding SelectedItem, ElementName=cboDate}" Margin="0" ItemsSource="{Binding FK_tblMany1_tblOne}"
                ItemTemplate="{StaticResource tblOneLink}" Name="cboOne" />
    

    Or in this way:

    <ComboBox Margin="0" ItemsSource="{Binding tblMany1/FK_tblMany1_tblOne}"
                ItemTemplate="{StaticResource tblOneLink}" Name="cboOne" />
    

    The slash sign in the codetblMany1/FK_tblMany1_tblOne indicates that the binding takes the current item of the tblMany1 collection and then takes the property FK_tblMany1_tblOne of that item.

    Edit
    Because there is only two tables and you want to display the same collection (but with different fields), the correct code might look so:

    <ComboBox Margin="0" ItemsSource="{Binding tblMany1}"
                ItemTemplate="{StaticResource tblOneLink}" Name="cboOne" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on a QR code encoding/decoding project. I have been read through
I have been working through the tutorial adapting it to a project I want
I have been working through a number of very odd issues with some DLL
I have been working through projects involving packages that do all the web design
I have been working my way through Scott Guthrie's excellent post on ASP.NET MVC
I'm starting out with wxPython and have been working my way through every tutorial
Over the years as I have gone through school and been working in the
I have been working with android for a little while now and feel pretty
I'm using Delphi 2009. In my program, I have been working very hard to
I have been working on a small exercise for my CIS class and am

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.