title: Grid in windows phone 7
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/6845896/grid-in-windows-phone-7">Grid in windows phone 7</a>  </p>
  </blockquote>
  
  
  
  <p>I am trying to <strong>divide a grid named "scheduleListBox" into 2 column</strong> and then place the <strong>time</strong> in the variable of <strong>"time"</strong> and the next column to place a button it.</p>
  
  <p>Below is my code:</p>
  
  <p>string selectedFolderName;</p>
  
  <pre><code>    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);
          }
      }
  }
  </code></pre>
  
  <p>But my above code gave me a error stating that <strong>Exception was unhandled: 0x8000ffff</strong>.</p>
  
  <p>How can i modify my above code?</p>