Solved

WPF Database CollectionViewSource Question

Posted on 2010-08-20
2
859 Views
Last Modified: 2013-12-17
I'm a WPF newbie so go easy on me.

Generally I've created a window to lookup a person in table.  After closing that window I want to display more information about that selected user.

In one dialog window I have used a DataGrid to select a row representing a person.
After selecting the person, I exit the dialog with the System.Data.DataRow information saved. In the calling dialog I have a CollectionViewSource that contains all of the people.  It seems like I should be able to use the row information that I've saved to move to the same row in the CollectionViewSource, but I can't find a way to do it.  Is there a better way to do this or is there just something that I'm missing?

//C# code saving the person in the find a person window.
selectedItem = dtgPerson.SelectedItem as FAPDataSet.TblPersonRow;

XAML CollectionViewSource binding to table
<CollectionViewSource x:Key="tblPersonViewSource" Source="{Binding Path=TblPerson, Source={StaticResource FAPDataSet}}" />

Thank you in advance for your help.




0
Comment
Question by:sbooth1117
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 13

Expert Comment

by:kaylanreilor
ID: 33509225
I suppose that you will have to navigate through your collection, for each item cast the CurrentItem as a FAPDataSet.TblPersonRow object and make a comparison (http://msdn.microsoft.com/en-us/library/ms754244.aspx).
Or you may want to implement a more complex procedure to allow some enhancement later on by using some filter, like allow a multi selection : http://bea.stollnitz.com/blog/?p=31.
0
 

Accepted Solution

by:
sbooth1117 earned 0 total points
ID: 33524735
I got it.  I just created a stored procedure that took a personID as the parameter.  Then after I find the person I do the following:

FAPDataSetTableAdapters.TblPersonTableAdapter dsFAPSearchTblPersonTableAdapter = new FAPDataSetTableAdapters.TblPersonTableAdapter();
dsFAPSearchTblPersonTableAdapter.FillBy(dsFAPSearch.TblPerson, person.PersonID);
System.Windows.Data.CollectionViewSource tblPersonViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("tblPersonViewSource")));
tblPersonViewSource.View.MoveCurrentToFirst();

Person.PersonID is ID of the person that has been selected and FillBy is the method that the disigner created based on the stored procedure that I created.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ASP.NET MVC -Update model when click on <li> element 29 104
Data organization issue 7 56
TFS 2015 Access denied. 1 34
PowerShell:  Use of subproperties in a Select statement 7 69
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question