我尝试填充数据网格视图但第一次无法正常工作。
在DataGrid视图中,列不会更新。第一次datagrid列为零,第二次正确更新列计数。
//_dtsource is nothing but DataView
Dgrid.ItemsSource = _dtsource;
Dgrid.Columns[0].Visibility = Visibility.Visible;
Dgrid.Columns[1].Visibility = Visibility.Visible;
Dgrid.Columns[2].Visibility = Visibility.Hidden;
XAML代码:
<Grid Height="642" Width="835">
<TextBlock HorizontalAlignment="Left" Margin="283,10,0,0" TextWrapping="Wrap" Text="Access Permissions" VerticalAlignment="Top" Width="200" Height="23" FontSize="14" FontWeight="Bold"/>
<TextBlock HorizontalAlignment="Left" Margin="10,68,0,0" TextWrapping="Wrap" Text="List Of Forms :" VerticalAlignment="Top" Width="100" Height="23"/>
<DataGrid x:Name="Dgrid" HorizontalAlignment="Left" Margin="10,111,0,0" VerticalAlignment="Top" Width="815" Height="353" Background="Transparent" BorderThickness="1" SelectionChanged="Dgrid_SelectionChanged" AutoGenerateColumns="False"/>
</Grid>