why is that we always get an extra column show in datagrid
i have four columns specfied but why is that i always see one extra column shown in the output
this is my xaml code
<Grid x:Name="LayoutRoot" Background="White" Height="492" Width="453">
<sdk:DataGrid MinHeight="100" x:Name="dgCounty" AutoGenerateColumns="False" VerticalAlignment="Top" Grid.Row="1" IsReadOnly="True" Margin="5,5,5,0" RowDetailsVisibilityChanged="dgCounty_RowDetailsVisibilityChanged" SelectionMode="Extended" RowDetailsVisibilityMode="VisibleWhenSelected">
<sdk:DataGrid.Columns>
<sdk:DataGridTemplateColumn>
<sdk:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button x:Name="myButton" Width="24" Height="24" Click="Details_Click">
<Image x:Name="img" Source="Images/detail.JPG" Stretch="None"/>
</Button>
</DataTemplate>
</sdk:DataGridTemplateColumn.CellTemplate>
</sdk:DataGridTemplateColumn>
<sdk:DataGridTemplateColumn Header="ID">
开发者_开发百科 <sdk:DataGridTemplateColumn.CellTemplate>
<DataTemplate >
<sdk:Label Content="{Binding EmployeeID}" />
</DataTemplate>
</sdk:DataGridTemplateColumn.CellTemplate>
</sdk:DataGridTemplateColumn>
<sdk:DataGridTemplateColumn Header="Name">
<sdk:DataGridTemplateColumn.CellTemplate>
<DataTemplate >
<sdk:Label Content="{Binding EmployeeFName}" />
</DataTemplate>
</sdk:DataGridTemplateColumn.CellTemplate>
</sdk:DataGridTemplateColumn>
<sdk:DataGridTemplateColumn Header="MailID">
<sdk:DataGridTemplateColumn.CellTemplate>
<DataTemplate >
<sdk:Label Content="{Binding EmployeeMailID}" />
</DataTemplate>
</sdk:DataGridTemplateColumn.CellTemplate>
</sdk:DataGridTemplateColumn>
</sdk:DataGrid.Columns>
</sdk:DataGrid>
is there any setting that we need to do to remove that extra column?
thanks in advance for the help.
You are talking about this last empty, quasi-column? If yes, the answer is here:
http://wpf.codeplex.com/Thread/View.aspx?ThreadId=58939
Works like a charm for me.
You can try to set the ColumnWidth property of the DataGrid to *. An alternative approach is to set the Width of your last column to *.
精彩评论