windows phone 7中的网格

本文关键字:网格 phone windows | 更新日期: 2023-09-27 18:03:27

可能重复:
windows phone 7 中的网格

我试图将一个名为"scheduleListBox"的网格划分为两列,然后将时间放在"时间">的变量中,并在下一列中放置一个按钮。

以下是我的代码:

字符串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);
        }
    }
}

但是上面的代码给了我一个错误,说明异常未得到处理:0x8000ffff

我如何修改上面的代码?

windows phone 7中的网格

Grid创建代码没有任何问题。异常很可能超出了它的范围。确保:

  • 您的应用程序未调用应用程序中未声明的功能舱单
  • 独立存储中的文件存在并且可以访问

在你的情况下达到循环了吗?