为什么我的清单没有出现?

时间:2015-04-15 14:35:40

标签: c# list windows-phone-7 grid

我有一个Grids列表但没有显示在我的页面中,调试器没有显示任何内容。我试图在xaml中做到这一点,但也没有奏效。有人可以帮帮我吗?

PS。我的课很好,stcList存在。

List<Grid> listaGrids = new List<Grid>();

        List<HyperlinkButton> listaLinks = new List<HyperlinkButton>();

        int i = 0;

        AppDataContext db = new AppDataContext();

        Pessoa pessoa = db.Pessoas.Single(c => c.Email == email);

        foreach (Coletor coletor in pessoa.Coletores)
        {
            if (coletor.Ativado == true)
            {
                Grid aux = new Grid();
                ColumnDefinition c1 = new ColumnDefinition();
                ColumnDefinition c2 = new ColumnDefinition();
                ColumnDefinition c3 = new ColumnDefinition();

                aux.Width = 400;
                aux.Height = 80;

                aux.VerticalAlignment = VerticalAlignment.Center;

                c1.Width = new System.Windows.GridLength(280);
                c2.Width = new System.Windows.GridLength(80);
                c3.Width = new System.Windows.GridLength(80);

                coletorAux = coletor;

                aux.ColumnDefinitions.Add(c1);
                aux.ColumnDefinitions.Add(c2);
                aux.ColumnDefinitions.Add(c3);

                RowDefinition r1 = new RowDefinition();

                aux.RowDefinitions.Add(r1);

                HyperlinkButton aux2 = new HyperlinkButton();
                aux2.Content = "Coletor " + (i + 1).ToString();
                aux2.FontSize = 34;
                aux2.NavigateUri = new Uri("/OcorrenciasPage.xaml?coletorId=" + coletor.Id.ToString(), UriKind.RelativeOrAbsolute);
                i++;

                Button btnEdit = new Button();

                var brush = new ImageBrush();

                brush.ImageSource = new System.Windows.Media.Imaging.BitmapImage(new Uri("/icons/edit.png", UriKind.RelativeOrAbsolute));

                btnEdit.Background = brush;

                btnEdit.Width = 80;
                btnEdit.Height = 80;

                btnEdit.Click += btnEdit_Click;

                Button btnDelete = new Button();

                ImageBrush brush2 = new ImageBrush();

                brush2.ImageSource = new System.Windows.Media.Imaging.BitmapImage(new Uri("/icons/delete.png", UriKind.RelativeOrAbsolute));

                btnDelete.Background = brush2;

                btnDelete.Width = 80;
                btnDelete.Height = 80;

                btnDelete.Click += btnDelete_Click;

                Grid.SetColumn(aux2, 0);
                Grid.SetColumn(btnEdit, 1);
                Grid.SetColumn(btnDelete, 2);
                Grid.SetRow(aux2, 0);
                Grid.SetRow(btnEdit, 0);
                Grid.SetRow(btnDelete, 0);

                listaGrids.Add(aux);


            }
        }

        ListBox coletores = new ListBox();
        coletores.ItemsSource = listaGrids;
        stcList.Children.Add(coletores);

0 个答案:

没有答案