Originally, order was used, but the program did not sort it.
DgrdDefinedMaterial. DataSource = RecipeDetailModel. MaterialDefinedList. OrderBy (e => e. Name). ToList ();
After modification
RecipeDetailModel. MaterialDefinedList = RecipeDetailModel. MaterialDefinedList. OrderBy (e => e. Name). ToList ();
Cause:
Because dgrdDefinedMaterial. DataBindings. Add ("DataSource", recipeDetailModel, "MaterialDefinedList") is used; bind,
Then in the object
Private List <MD_Material> materialDefinedList;
[DataMember]
Public List <MD_Material> MaterialDefinedList
{
Get {return materialDefinedList ;}
Set
{
MaterialDefinedList = value;
NotifyPropertyChanged ("MaterialDefinedList ");
}
}
When dgrdDefinedMaterial. DataSource = RecipeDetailModel. MaterialDefinedList. OrderBy (e => e. Name). ToList,
DgrdDefinedMaterial. DataSource is sorted, but RecipeDetailModel. MaterialDefinedList does not,
Therefore, you must assign a value to the RecipeDetailModel. MaterialDefinedList