2011-07-26 7 views
0

可能性の重複に:
Grid in windows phone 7グリッドのWindows Phone 7

私は除算に2列に "scheduleListBox" という名前のグリッドをしようとしていますし、その後に時間を置きます変数「時間」とそれにボタンを置くための次の列。以下は

私のコードです:

文字列selectedFolderName。 0x8000ffffが返さ:

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); 
     } 
    } 
} 

しかし、私の上記のコードは私に例外が未処理だったことを示すエラーが発生しました。

上記のコードを変更するにはどうすればよいですか?

+0

XAMLとデータバインディングを使用していないのはなぜですか? –

+1

私はこのメソッドを試してみたかったので。私は –

+0

の前にデータバインドを行ったので、コード行をエラーごとに一行ずつコメントアウトしてください。あなたは何が間違っていたかを知っている –

答えて

0

Grid作成コードに問題はありません。例外はその範囲外です。ていることを確認してください:

  • あなたのアプリケーションが起動されていない機能が
  • 存在し、アクセス可能である分離ストレージ内のファイル アプリマニフェストで宣言されていないが

ループがあなたの状況に達していますか?

関連する問題