2011-07-26 4 views
0

가능한 중복 :
Grid in windows phone 7그리드 7

내가 2 열에 나누기 "scheduleListBox"라는 그리드에 노력하고있는 시간을 배치하고 "time"의 변수와 다음 열은 버튼을 배치합니다. 다음은

내 코드입니다 :

문자열 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에 아무런 문제가 없습니다. 예외는 그 범위를 벗어나 있습니다. 있는지 확인하십시오

  • 응용 프로그램이 호출되지 않은 기능을
  • 존재하고 액세스 할 수있는 격리 된 저장소에 파일 앱 매니페스트에 선언되지는

루프는 상황에 도달?