2

我需要创建一个只显示 6 行和 0 列的数据网格。我创建了一个用户控件,其中包含以下数据网格

<sdk:DataGrid Grid.Column="1" x:Name="Customisedgrid" BorderBrush="GreenYellow"     
     BorderThickness="3" Background="Aqua" AutoGenerateColumns="False" 
     HorizontalAlignment="Left" Height="281" Margin="48,98,0,0" 
     Style="{StaticResource CustomDataGridStyle}" VerticalAlignment="Top" 
     Width="384" Itemsource ="{Binding S_BindData}"  
     CellStyle="{StaticResource DataGridCellStyle1}">

一旦我的用户控件准备就绪,我将在 mainpage.cs 中引用它,如下所示

private void ContentPanel_Loaded(object sender, RoutedEventArgs e)
{
  //instance of my usercontrol
  CustomGrid custom = new CustomGrid();
  //added my usercontrol to a stackpanel(GridOuterPanel)
  GridOuterPanel.Children.Add(custom);
}

我的问题是,一旦我运行我的应用程序,我没有得到任何数据网格,我只查看一个空白页......

4

0 回答 0