Click here to Skip to main content
15,908,172 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Data Access for dummies... Pin
Johnny J.12-Apr-11 5:34
professionalJohnny J.12-Apr-11 5:34 
GeneralRe: Data Access for dummies... Pin
Ian Shlasko12-Apr-11 6:28
Ian Shlasko12-Apr-11 6:28 
AnswerRe: Data Access for dummies... Pin
Abhinav S12-Apr-11 4:35
Abhinav S12-Apr-11 4:35 
AnswerRe: Data Access for dummies... Pin
Vimalsoft(Pty) Ltd12-Apr-11 21:25
professionalVimalsoft(Pty) Ltd12-Apr-11 21:25 
GeneralRe: Data Access for dummies... Pin
Johnny J.12-Apr-11 21:51
professionalJohnny J.12-Apr-11 21:51 
GeneralRe: Data Access for dummies... Pin
Vimalsoft(Pty) Ltd12-Apr-11 22:01
professionalVimalsoft(Pty) Ltd12-Apr-11 22:01 
AnswerRe: Data Access for dummies... Pin
V.13-Apr-11 0:41
professionalV.13-Apr-11 0:41 
QuestionMaster/Detail works but why ? and more Pin
Jean-Louis Leroy11-Apr-11 23:19
Jean-Louis Leroy11-Apr-11 23:19 
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:

<ListBox Name="listBoxUsers" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding}" DisplayMemberPath="ReportingUser" />
<ListBox Grid.Row="1" Name="listBoxSelectedReporting" ItemsSource="{Binding User_ReportingUser}"
   DisplayMemberPath="Row.ReportingRow.ReportingName" />

...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 but the designer only allows SQL code that returns a single value. So I created a TableAdapter with the following SQL:

SELECT     ReportingCode, ReportingName
FROM         Reporting AS r
WHERE     (NOT EXISTS (
  SELECT ReportingCode
  FROM ReportingUser AS u
  WHERE(ReportingCode = r.ReportingCode) AND (ReportingUser = @ReportingUser)))

Here again the "content" of the table is parameterized by the same ReportingUser. How can I make the listbox for the non-selected reports coordinate automagically with the User master control ?
QuestionBinding List of Objects in CommandParameter Pin
NTheOne10-Apr-11 23:30
NTheOne10-Apr-11 23:30 
AnswerRe: Binding List of Objects in CommandParameter Pin
Abhinav S11-Apr-11 1:50
Abhinav S11-Apr-11 1:50 
QuestionPolyline rendering error in silverlight Pin
chenjch10-Apr-11 5:47
chenjch10-Apr-11 5:47 
QuestionWPF/VB.NET Memory Leaks - reproducible, when creating multiple RichText controls in a WPF form. Grrrrr! Pin
JohnyPoo9-Apr-11 14:54
JohnyPoo9-Apr-11 14:54 
QuestionMVVM : Assign ItemSource in View's Code Behind Pin
NTheOne8-Apr-11 23:56
NTheOne8-Apr-11 23:56 
AnswerRe: MVVM : Assign ItemSource in View's Code Behind Pin
SledgeHammer019-Apr-11 8:10
SledgeHammer019-Apr-11 8:10 
GeneralRe: MVVM : Assign ItemSource in View's Code Behind Pin
NTheOne10-Apr-11 18:15
NTheOne10-Apr-11 18:15 
GeneralRe: MVVM : Assign ItemSource in View's Code Behind Pin
Mycroft Holmes10-Apr-11 18:29
professionalMycroft Holmes10-Apr-11 18:29 
AnswerRe: MVVM : Assign ItemSource in View's Code Behind Pin
Abhinav S10-Apr-11 18:47
Abhinav S10-Apr-11 18:47 
QuestionGet Data from ViewModel in Code behind using MVVM Pin
NTheOne8-Apr-11 21:58
NTheOne8-Apr-11 21:58 
AnswerRe: Get Data from ViewModel in Code behind using MVVM Pin
Mycroft Holmes8-Apr-11 22:22
professionalMycroft Holmes8-Apr-11 22:22 
AnswerRe: Get Data from ViewModel in Code behind using MVVM Pin
Abhinav S8-Apr-11 22:35
Abhinav S8-Apr-11 22:35 
AnswerRe: Get Data from ViewModel in Code behind using MVVM Pin
SledgeHammer019-Apr-11 8:07
SledgeHammer019-Apr-11 8:07 
QuestionChange the display of a combobox control into hyperlink Pin
Rocky237-Apr-11 20:57
Rocky237-Apr-11 20:57 
AnswerRe: Change the display of a combobox control into hyperlink Pin
Mycroft Holmes7-Apr-11 22:20
professionalMycroft Holmes7-Apr-11 22:20 
AnswerRe: Change the display of a combobox control into hyperlink Pin
SledgeHammer018-Apr-11 7:57
SledgeHammer018-Apr-11 7:57 
QuestionDataGrid CellTemplate / CellEditingTemplate Pin
eddieangel7-Apr-11 9:31
eddieangel7-Apr-11 9:31 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.