Answered by:
wpf + ef + datagrid + sorting = beurk...

Question
-
i have :
1 form with controls to edit a record (myrecord)
1 grid on this form to edit sub details records (myrecord.details)
it seems very very complicated to sort the datagrid according one column ???
yes, i have been searching the forum and googling around, but it seems you need to write at least 10 lines of code just to do this, and you have to use subcollections that i never heard of...
seems that EF is still is way to complicated... it helps you save 50 lines of code to link one table to a class (object) but then you loose plenty of time in all forms all around your software... doesn't look like a progress... brr...
SteveSunday, August 21, 2011 7:34 AM
Answers
-
Hi,
Have you tried to use an ObservableCollection ? I gave it a try using the Northwind sample database and
NorthwindEntities db=new NorthwindEntities(); dg.ItemsSource = new ObservableCollection<Categories>(db.Categories);
is enough to sort on the id, name or description when I click the column.
Perhaps could you point us on one of the article you saw so that we can better understand the context in which the code you are talking about is needed.
Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".- Marked as answer by Alan_chen Monday, August 29, 2011 3:04 AM
Sunday, August 21, 2011 1:29 PM -
Hi Steve,
Welcome!
@Patrice is right!
I think you can refer this link: Code First Model with Master-Detail WPF Application
Have a nice day.
Alan Chen[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Marked as answer by Alan_chen Monday, August 29, 2011 3:04 AM
Monday, August 22, 2011 3:26 AM -
I ended up encapsulating all this in a :
ObservableCollection, ListCollectionView, pretty much a lot of code for not something special... seems to work now. but it just refrain me to use more ef+wpf...
thanks anyway for the tips
Steve- Marked as answer by Alan_chen Monday, August 29, 2011 3:04 AM
Sunday, August 28, 2011 10:03 AM
All replies
-
Hi,
Have you tried to use an ObservableCollection ? I gave it a try using the Northwind sample database and
NorthwindEntities db=new NorthwindEntities(); dg.ItemsSource = new ObservableCollection<Categories>(db.Categories);
is enough to sort on the id, name or description when I click the column.
Perhaps could you point us on one of the article you saw so that we can better understand the context in which the code you are talking about is needed.
Please always mark whatever response solved your issue so that the thread is properly marked as "Answered".- Marked as answer by Alan_chen Monday, August 29, 2011 3:04 AM
Sunday, August 21, 2011 1:29 PM -
Hi Steve,
Welcome!
@Patrice is right!
I think you can refer this link: Code First Model with Master-Detail WPF Application
Have a nice day.
Alan Chen[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
- Marked as answer by Alan_chen Monday, August 29, 2011 3:04 AM
Monday, August 22, 2011 3:26 AM -
Hi,
I am writing to check the status of the issue on your side. Would you mind letting us know the result of the suggestions?
If you need further assistance, please feel free to let me know. I will be more than happy to be of assistance.
Have a nice day.
Alan Chen[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Friday, August 26, 2011 3:22 AM -
and can you edit the items in the grid as well ?
thanks for your post
Steve
SteveSunday, August 28, 2011 9:58 AM -
I ended up encapsulating all this in a :
ObservableCollection, ListCollectionView, pretty much a lot of code for not something special... seems to work now. but it just refrain me to use more ef+wpf...
thanks anyway for the tips
Steve- Marked as answer by Alan_chen Monday, August 29, 2011 3:04 AM
Sunday, August 28, 2011 10:03 AM