Click here to Skip to main content
15,913,773 members
Home / Discussions / WPF
   

WPF

 
QuestionWritableBitmap in silverlight3 Pin
VCsamir14-May-09 20:07
VCsamir14-May-09 20:07 
AnswerRe: WritableBitmap in silverlight3 Pin
Ray Cassick15-May-09 2:39
Ray Cassick15-May-09 2:39 
GeneralRe: WritableBitmap in silverlight3 Pin
VCsamir17-May-09 20:08
VCsamir17-May-09 20:08 
QuestionMultiselect mode not working for listview control containing a Gridview Pin
S Rajput14-May-09 16:12
S Rajput14-May-09 16:12 
AnswerRe: Multiselect mode not working for listview control containing a Gridview Pin
Mark Salsbery15-May-09 7:04
Mark Salsbery15-May-09 7:04 
AnswerRe: Multiselect mode not working for listview control containing a Gridview Pin
Niladri_Biswas13-Jun-09 3:43
Niladri_Biswas13-Jun-09 3:43 
QuestionPrism with DockManager Pin
Michael Sync14-May-09 15:51
Michael Sync14-May-09 15:51 
QuestionHow to get event of button inside stackpanel?very urgent.... Pin
salon14-May-09 4:23
salon14-May-09 4:23 
AnswerRe: How to get event of button inside stackpanel?very urgent.... Pin
Mark Salsbery14-May-09 7:07
Mark Salsbery14-May-09 7:07 
GeneralRe: How to get event of button inside stackpanel?very urgent.... Pin
salon17-May-09 20:09
salon17-May-09 20:09 
GeneralRe: How to get event of button inside stackpanel?very urgent.... Pin
VbGuru61326-Aug-10 7:58
VbGuru61326-Aug-10 7:58 
QuestionSorting ObservableCollection Pin
Kunal Chowdhury «IN»14-May-09 0:21
professionalKunal Chowdhury «IN»14-May-09 0:21 
AnswerRe: Sorting ObservableCollection Pin
Pete O'Hanlon14-May-09 1:39
mvePete O'Hanlon14-May-09 1:39 
AnswerRe: Sorting ObservableCollection Pin
Kunal Chowdhury «IN»14-May-09 2:21
professionalKunal Chowdhury «IN»14-May-09 2:21 
GeneralRe: Sorting ObservableCollection Pin
BlitzPackage14-May-09 9:41
BlitzPackage14-May-09 9:41 
GeneralRe: Sorting ObservableCollection Pin
Pete O'Hanlon14-May-09 10:25
mvePete O'Hanlon14-May-09 10:25 
GeneralRe: Sorting ObservableCollection Pin
Kunal Chowdhury «IN»14-May-09 20:54
professionalKunal Chowdhury «IN»14-May-09 20:54 
GeneralRe: Sorting ObservableCollection Pin
Pete O'Hanlon14-May-09 22:29
mvePete O'Hanlon14-May-09 22:29 
GeneralRe: Sorting ObservableCollection Pin
Kunal Chowdhury «IN»14-May-09 23:15
professionalKunal Chowdhury «IN»14-May-09 23:15 
GeneralRe: Sorting ObservableCollection Pin
Pete O'Hanlon15-May-09 0:40
mvePete O'Hanlon15-May-09 0:40 
AnswerRe: Sorting ObservableCollection Pin
Michael Sync14-May-09 15:58
Michael Sync14-May-09 15:58 
The easiest way to do this is using LINQ. That way will work on both Silverlight and WPF.

For example:

Your class

public class MyData {
            public string Caption;
            public double Result;
        }


Fill data

ObservableCollection<MyData> data = new ObservableCollection<MyData>();
            data.Add(new MyData(){ Caption = "A", Result = 10 });
            data.Add(new MyData() { Caption = "B", Result = 1 });
            data.Add(new MyData() { Caption = "C", Result = 5 });
            data.Add(new MyData() { Caption = "D", Result = 3 });


LINQ for sorting ObservableCollection

var sortedData = from mydata in data
                 orderby mydata.Result
                 select mydata;


Showing the result

foreach (var d in sortedData) {
               Console.WriteLine(d.Caption + " - " + d.Result.ToString());
           }


Hope it helps.

Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)


GeneralRe: Sorting ObservableCollection Pin
BlitzPackage15-May-09 15:32
BlitzPackage15-May-09 15:32 
GeneralRe: Sorting ObservableCollection Pin
Michael Sync15-May-09 22:19
Michael Sync15-May-09 22:19 
GeneralRe: Sorting ObservableCollection Pin
Kevin McFarlane16-May-09 6:37
Kevin McFarlane16-May-09 6:37 
AnswerRe: Sorting ObservableCollection Pin
Sebastian Solnica22-Nov-09 22:43
Sebastian Solnica22-Nov-09 22:43 

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.