0
我想對我檢索的數據進行排序。 我有兩個數據時間和附加標題。 我能排序的時間。 但附註不符合排序安排。Windows Phone 7中的數組排序
例如,時間 - > 10:45 AM附標題 - >作業8:45 AM - >工作
時間排序 時間 8:45 AM作業 10:50 AM工作
保護覆蓋無效的OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs E)
{
base.OnNavigatedTo(e);
selectedFolderName = "";
if (NavigationContext.QueryString.TryGetValue("selectedFolderName", out selectedFolderName))
selectedFolderName1 = selectedFolderName;
IsolatedStorageFile myStore = IsolatedStorageFile.GetUserStoreForApplication();
//For time
try
{
StreamReader readFileTime = new StreamReader(new IsolatedStorageFileStream(selectedFolderName1 + "\\time.Schedule", FileMode.Open, myStore));
//For title
StreamReader readFileTitle = new StreamReader(new IsolatedStorageFileStream(selectedFolderName1 + "\\title.Schedule", FileMode.Open, myStore));
//For category
StreamReader readFileCategory = new StreamReader(new IsolatedStorageFileStream(selectedFolderName1 + "\\category.Schedule", FileMode.Open, myStore));
String timeText = readFileTime.ReadLine();
timeSplit = timeText.Split(new char[] { '^' });
Array.Sort(timeSplit);
String titleText = readFileTitle.ReadLine();
titleSplit = titleText.Split(new char[] { '^' });
String categoryText = readFileCategory.ReadLine();
categorySplit = categoryText.Split(new char[] { '^' });
}
catch (Exception)
{
// noScheduleTxt.Visibility = Visibility.Visible;
}
if (scheduleListBox.Items.Count == 0)
{
for (int i = 0; i < timeSplit.Length; i++)
{
string timeList = timeSplit[i];
string titleList = titleSplit[i];
string categoryList = categorySplit[i];
//Define grid column, size
Grid schedule = new Grid();
//Column to hold the time of the schedule
ColumnDefinition timeColumn = new ColumnDefinition();
GridLength timeGrid = new GridLength(110);
timeColumn.Width = timeGrid;
schedule.ColumnDefinitions.Add(timeColumn);
//Text block that show the time of the schedule
TextBlock timeTxtBlock = new TextBlock();
timeTxtBlock.Text = timeList;
//Set the alarm label text block properties - margin, fontsize
timeTxtBlock.FontSize = 28;
timeTxtBlock.Margin = new Thickness(0, 20, 0, 0);
//Set the column that will hold the time of the schedule
Grid.SetColumn(timeTxtBlock, 0);
schedule.Children.Add(timeTxtBlock);
//Column to hold the title of the schedule
ColumnDefinition titleColumn = new ColumnDefinition();
GridLength titleGrid = new GridLength(300);
titleColumn.Width = titleGrid;
schedule.ColumnDefinitions.Add(titleColumn);
//Text block that show the title of the schedule
TextBlock titleTxtBlock = new TextBlock();
titleTxtBlock.Text = titleSplit[i];
if (titleSplit[i].Length > 15)
{
string strTitle = titleSplit[i].Substring(0, 15) + "....";
titleTxtBlock.Text = strTitle;
}
else
{
titleTxtBlock.Text = titleSplit[i];
}
//Set the alarm label text block properties - margin, fontsize
titleTxtBlock.FontSize = 28;
titleTxtBlock.Margin = new Thickness(20, 20, 0, 0);
//Set the column that will hold the title of the schedule
Grid.SetColumn(titleTxtBlock, 1);
schedule.Children.Add(titleTxtBlock);
//Column 3 to hold the image category of the schedule
ColumnDefinition categoryImageColumn = new ColumnDefinition();
GridLength catImgnGrid = new GridLength(70);
categoryImageColumn.Width = catImgnGrid;
schedule.ColumnDefinitions.Add(categoryImageColumn);
//Text block that show the category of the schedule
TextBlock categoryTxtBlock = new TextBlock();
categoryTxtBlock.Text = categorySplit[i];
//set the category image and its properties - margin, width, height, name, background, font size
Image categoryImage = new Image();
categoryImage.Margin = new Thickness(-20, 15, 0, 0);
categoryImage.Width = 50;
categoryImage.Height = 50;
if (categoryTxtBlock.Text == "Priority")
{
categoryImage.Source = new BitmapImage(new Uri("/AlarmClock;component/Images/exclamination_mark.png", UriKind.Relative));
}
else
if (categoryTxtBlock.Text == "Favourite")
{
categoryImage.Source = new BitmapImage(new Uri("/AlarmClock;component/Images/star_full.png", UriKind.Relative));
}
Grid.SetColumn(categoryImage, 2);
schedule.Children.Add(categoryImage);
scheduleListBox.Items.Add(schedule);
}
}
}
對不起你是什麼意思?我可以舉個例子嗎? –
只需編輯我的帖子。希望有助於 – Mariusz
我編輯了我的代碼並將其發佈到上面。我編輯的是正確的嗎? –