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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T15:57:41+00:00 2026-05-16T15:57:41+00:00

i have generated a Linq to Sql class which looks like this. so i

  • 0

i have generated a Linq to Sql class which looks like this.

alt text

so i have 3 querys which gets my data.

private IQueryable<Gesellschaft> loadedGesellschaft;
private IQueryable<Anschrift> loadedGesellschaftAnschrift;
private IQueryable<Email> loadedGesellschaftEmail;
private lgDataContext completeGesellschaft;

private void Button_Click(object sender, RoutedEventArgs e)
    {
        completeGesellschaft = new lgDatacontext();
        loadedGesellschaft = completeGesellschaft.Gesellschaft.Where(gid => gid.GID == 2);
        loadedGesellschaftAnschrift = completeGesellschaft.Anschrift.Where(FK_GID => FK_GID.FK_GesellschaftId == loadedGesellschaft.First().GID);
        loadedGesellschaftEmail = completeGesellschaft.Email.Where(FK_GID => FK_GID.FK_AnschriftId == loadedHauptanschrift.First().idAnschrift);
    }

After this i want to put these 3 on my page. The Result is something like this there one Office(loadedGesellschaft) and that has maybe more than one Adress(loadedGesellschaftAnschrift) and has maybe more than one Email(loadedGesellschaftEmail)
so i have on my window some textboxes which contain the fields from loadedGesellschaft and Adresses and Emails are stored in comboboxes.

do i always have to bind the itemsource of one Control e.g.

<ComboBox Name="CBox_GDEmail" />

CBoxGDEmail.Itemsource = loadedGesellschaftEmail;

or is there an possibility to put all three objects together to the datacontext of the window ?

  • 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-16T15:57:41+00:00Added an answer on May 16, 2026 at 3:57 pm

    First, create three classes: Gesellschaft, Anschrift, and Email. These classes are view models; they expose any property whose value you want to see in the view. Make Gesellschaft expose an Anschriften property of type IEnumerable<Anschrift>, and Anschrift expose an Emails property of type IEnumerable<Email>. (I’m just sort of guessing at what the plural of Anschrift is; pretty much all of my knowledge of German comes from board games.)

    In your XAML, create three DataTemplates, e.g.:

    <DataTemplate DataType="{x:Type local:Gesellschaft}">
       <WrapPanel>
          <Label>Name</Label>
          <TextBlock Text="{Binding Gesellschaftname}"/>
          ...
          <ListBox ItemsSource="{Binding Anschriften}"/>
      </WrapPanel>
    </DataTemplate>
    

    Obviously you’ll want to use a saner layout than sticking a bunch of controls in a WrapPanel; this is just a proof of concept. The DataTemplate for Anschrift should similarly have a ListBox whose ItemsSource is bound to Emails.

    Once you’ve done this, all you need in your XAML is to set the DataContext of a ContentPresenter to an instance of Gesellschaft. It will be rendered using the DataTemplate that you’ve defined for that type. Its ListBox will contain an item for each Anschrift, rendered using that type’s template. U.s.w.

    Congratulations, you’re now using the MVVM pattern just like all the cool kids. There’s a lot more to learn about than just this, but this is a good start.

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

Sidebar

Related Questions

i have my auto-generated linq to sql classes, and i extend this class using
What I have: LINQ to SQL auto generated class, which corresponds to the shape
I have a bunch of entity class (generated by Linq to SQL) with a
I've got a LINQ 2 SQL generated class I'd like to expose through a
I have a LINQ to SQL class called Data with a column of type
I would like to be able to subclass automatically generated LINQ to SQL Data
I have this contact list which I'm building using LINQ to SQL. The query
I have two tables, with foreign key. linq to sql class generated for me
I have a Linq-to-SQL class, and I'd like to perform some pre-save validation before
I have a LINQ to SQL generated class with a readonly property: <Column(Name:=totalLogins, Storage:=_TotalLogins,

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.