Grid in windows phone 7 [duplicate]
Possible Duplicate:
Grid in windows phone 7
I am trying to divide a grid named "scheduleListBox" into 2 column and then place the time in the variable of "time" and the next column to place a button it.
Below is my code:
string selectedFolderName;
string selectedFolderName1;
string[] timeSplit;
string timeSaved;
string timeList;
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
{
base.OnNavigatedTo(e);
selectedFolderName = "";
if (NavigationContext.QueryString.TryGetValue("selectedFolderName", out selectedFolderName))
selectedFolderName1 = selectedFolderName;
IsolatedStorageFile myStore = IsolatedStorageFile.GetUserStoreForApplication();
StreamReader readFile = new StreamReader(new IsolatedStorageFileStream( selectedFolderName1 + "\\time.Schedule", FileMode.Open, myStore));
String timeText = readFile.ReadLine();
timeSplit = timeText.Split(new char[] { '^' });
foreach (var time in timeSplit)
{
timeList = time;
MessageBox.Show("time " + timeList);
//Define grid column, size
Grid schedule = new Grid();
ColumnDefinition scheduleTitleColumn = new ColumnDefinition();
//grid1 to hold the label of the alarm
GridLength titleGrid = new GridLength(320);
scheduleTitleColumn.Width = titleGrid;
schedule.ColumnDefinitions.Add(scheduleTitleColumn);
ColumnDefinition viewBtnColumn = new ColumnDefinition();
//gl2 to hold the view alarm button
GridLength viewBtnGrid = new GridLength(80);
viewBtnColumn.Width = titleGrid;
schedule.ColumnDefinitions.Add(viewBtnColumn);
//text block that show the label of the alarm
TextBlock titleTxtBlock = new TextBlock();
titleTxtBlock.Text = time;
//Set the alarm label text block properties - margin, fontsize
titleTxtBlock.FontSize = 30;
titleTxtBlock.Margin = new Thickness(20, 20, 0, 0);
Grid.SetColumn(titleTxtBlock, 0);
//set the view alarm details button and its properties - margin, width, height, name, background, font size
HyperlinkButton viewButton = new HyperlinkButton();
viewButton.Margin = new Thickness(-150, 20, 0, 0);
viewButton.Width = 100;
viewButton.Height = 50;
viewButton.Name = time;
viewButton.Background = new ImageBrush { ImageSource = new BitmapImage(new Uri("/AlarmClock;component/Images/page_preview.png", UriKind.Relative)) };
viewButton.FontSize = 30;
//viewButton.开发者_开发技巧NavigateUri = new Uri("/viewAlarmClock.xaml?label=" + timeList, UriKind.Relative);
Grid.SetColumn(viewButton, 1);
schedule.Children.Add(titleTxtBlock);
schedule.Children.Add(viewButton);
//Add the alarm details to alarmListBox
scheduleListBox.Items.Add(schedule);
}
}
}
But my above code gave me a error stating that Exception was unhandled: 0x8000ffff.
How can i modify my above code?
There is nothing wrong with the Grid
creation code. The exception is outside its scope, most likely. Make sure that:
- Your application is not invoking capabilities not declared in the app manifest
- The file in the Isolated Storage exists and is accessible
Is the loop reached in your situation?
精彩评论