I perform ListCollectionView AddNewItem after adding objects, IndexOf returns the index to 1, I don't know what reason be?
The code is as follows:
The List PortNoindexData=https://bbs.csdn.net/topics/new List ()
{
New ComboBoxItem () {Content=1, VerticalAlignment=VerticalAlignment. Center, FontSize=14},
New ComboBoxItem () {Content=2, VerticalAlignment=VerticalAlignment. Center, FontSize=14},
New ComboBoxItem () {Content=3, VerticalAlignment=VerticalAlignment. Center, FontSize=14},
New ComboBoxItem () {Content=4, VerticalAlignment=VerticalAlignment. Center, FontSize=14},
New ComboBoxItem () {Content=5, VerticalAlignment=VerticalAlignment. Center, FontSize=14},
New ComboBoxItem () {Content=6, VerticalAlignment=VerticalAlignment. Center, FontSize=14},
};
ComboBox_PortNo. ItemsSource=PortNoindexData;
ListCollectionView viewPort=(ListCollectionView) CollectionViewSource. GetDefaultView (ComboBox_PortNo. ItemsSource);
//viewPort had already deleted PortNoindexData [2]
ViewPort. AddNewItem (PortNoindexData [2]);
ViewPort.Com mitNew ();
ViewPort. IndexOf (PortNoindexData [2]);