in Education by
I have a WPF application in which I use entity framework with mysql connector/net to obtain data back. I have a combobox which is filled with items from a table. A datagrids itemssource property is binded to the combobox' selecteditem.staff property, which displays the data correctly. The problem is that I am unable to sort this data. If I bind the data directly to the datagrid, the sorting works correctly. However if I bind the data to the combobox, then bind the datagrid to the selected item of the grid, the sorting is lost. Entity Framework Data Retrieval private void RefreshOffices() { try { using (var context = new LDC_Entities()) { cmbOffice.ItemsSource = context.Offices.Include("Staff.Roles").Include("Manager").ToList(); } } catch (Exception eX) { MessageBox.Show(String.Format("Unable to retrieve offices\nError:{0}", eX.Message),"Error", MessageBoxButton.OK, MessageBoxImage.Error); } } XAML Binding Any help would be much appreciated, I have tried playing with the CanUserSort property of the datagrid to no success. I believe it is to do with how the datagrid is filled not by the selected item, but by the .staff collection of staff members. Thanks in advance, Mike JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
First I would try to specify binding direction with Mode for DataGrid, like this if this doesn't work for you, another solution could be: First bind SelectedItem of the combo to a property, DataGrid bind to another collection. On combo binded change, populate DataGrid's binded collection with sorted data. Hope this helps.

Related questions

0 votes
    I have a WPF application in which I use entity framework with mysql connector/net to obtain data back. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    what i want : i have a config file where it contains some urls in .json file stored in asset ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    read the data from employee. text file and sort on age using counting sort,merge sort,quick sort and write ... sortedemponage.txt'. Select the correct answer from above options...
asked Dec 22, 2021 in Education by JackTerrance
0 votes
    All, I am trying to use syncfusion data grid in xamarin forms now.I have installed trial version as ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 23, 2022 in Education by JackTerrance
0 votes
    I know that this should be easy but how do I export/save a DataGridView to excel? JavaScript questions ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 16, 2022 in Education by JackTerrance
0 votes
    I have a DataGrid which usually contains approx 30 rows it rarely goes above 200. My problem is when ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 16, 2022 in Education by JackTerrance
0 votes
    I have two forms: frmClient', (which has a subform that lists applicants), and frmDisclosure', which ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 17, 2022 in Education by JackTerrance
0 votes
    I do not how can I fix this problem, "Permission Denied". I just want to make my combobox, ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    I have 10 ComboBox controls that will use the same item template (an Image and a Textblock), and ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    I have converted a few DropDownLists to jQuery comboboxes to add auto complete functionality etc. however, there ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    I have converted a few DropDownLists to jQuery comboboxes to add auto complete functionality etc. however, there ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
0 votes
    I've met an unknown error while inserting data into the database. The LogCat had been display "unable to insert data", ... I placed into my onClick(), it failed. onStart():...
asked Feb 9, 2022 in Education by JackTerrance
0 votes
    I've met an unknown error while inserting data into the database. The LogCat had been display "unable to insert data", ... I placed into my onClick(), it failed. onStart():...
asked Feb 5, 2022 in Education by JackTerrance
0 votes
    I am trying to implement a behavior for my draggable items. The behavior is described here : My box ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    How to sort a data.table using vector of multiple columns in R? Select the correct answer from above options...
asked Feb 1, 2022 in Education by JackTerrance
...