Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. WPF
  4. Master/Detail works but why ? and more

Master/Detail works but why ? and more

Scheduled Pinned Locked Moved WPF
questiondatabasecsharpwpf
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jean Louis Leroy
    wrote on last edited by
    #1

    Hello, I have a listbox of "users", when one is selected I want to display two listboxes: one containing the "reports" associated to the user, the other one the "other" reports. And buttons to move reports between the two listboxes. Very common scenario. Users and reports are stored in a database accessed via ADO.NET. I have the following tables:

    User: ReportingUser varchar(20) primary key
    Reporting: ReportingCode varchar(20) primary key, ReportingName varchar(20)
    ReportingUser: ReportingUser varchar(20), ReportingCode varchar(20)

    I imported the tables in designer and added two Relations: User_ReportingUser: ReportingUser.ReportingUser *->1 User.ReportingUser FK_Reporting_ReportingUser: ReportingUser.ReportingCode *->1 Reporting.ReportingCode The first relation is what my window edits. The second if for fishing the report name and display that instead of the report code. I have the following XAML:

    ...and Window_Loaded handler:

          userAdapter = new UserTableAdapter();
          reportingUserAdapter = new ReportingUserTableAdapter();
          reportingTableAdapter = new ReportingTableAdapter();
          dataset = new DNLMHDataSet();
          userAdapter.Fill(dataset.User);
          reportingTableAdapter.Fill(dataset.Reporting);
          reportingUserAdapter.Fill(dataset.ReportingUser);
          listBoxUsers.DataContext = dataset.User;
          listBoxSelectedReporting.DataContext = dataset.User;
    

    It's amazing to see that this suffices to give me master/detail behavior. My first question is: why does this work? Is there a compact explanation of this somewhere ? I googled around and did find information, e.g. about IsSynchronizedWithCurrentItem, but it's not enough to enlighten me. Where is the "current item" stored ? In listBoxUsers ? How is the other listbox aware that the current item has changed ? The "content" of the User_ReportingUser Relation is parameterized by the currently selected user. How does the ItemsSource of the Report listbox know which user is current ? What's the activity diagram ? Also, now I would like to implement the reports that are not selected for the current user. First I tried to create a query for that

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups