WPF Grid Left Whitish删除

时间:2014-02-22 15:54:52

标签: wpf datagrid wpf-controls wpfdatagrid

我已经在WPF中填充了一个数据网格,但我不知道它在网格左侧生成按钮类型的东西,我想删除它,我怎么能删除它,任何想法?

这是屏幕截图:

enter image description here

这是我的xaml代码:

        <DataGrid Name="Patients" SelectedValuePath="patientid" CanUserResizeRows="False"   Background="#942E2A" GridLinesVisibility="None" HorizontalGridLinesBrush="#73261E" BorderBrush="#73261E" BorderThickness="5"  SelectionChanged="Patients_SelectionChanged" ItemsSource="{Binding}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10" AutoGenerateColumns="False" Height="400" Width="340">

            <DataGrid.Resources>
                <Style TargetType="{x:Type DataGridColumnHeader}">
                    <Setter Property="Background" Value="#942E2A" />
                    <Setter Property="FontSize" Value="18" />
                    <Setter Property="Width" Value="150" />
                    <Setter Property="FontFamily" Value="Georgia" />
                    <Setter Property="Foreground" Value="White" />
                    <Setter Property="FontWeight" Value="Bold" />
                </Style>
                <Style TargetType="DataGridRow">
                    <Setter Property="Background" Value="#942E2A" />
                    <Setter Property="FontSize" Value="14" />
                    <Setter Property="FontFamily" Value="Georgia" />
                    <Setter Property="Foreground" Value="White" />

                    <Style.Triggers>
                        <Trigger Property="IsSelected"
                Value="True">
                            <Setter Property="BorderBrush"
                Value="White" />
                            <Setter Property="BorderThickness"
                Value="2" />
                            <Setter Property="Background"
                Value="White" />
                            <Setter Property="Foreground" Value="Black"></Setter>
                        </Trigger>
                    </Style.Triggers>

                </Style>
            </DataGrid.Resources>

            <DataGrid.Columns>

                <DataGridTemplateColumn Header="Patient ID" SortMemberPath="patientid" Width="Auto" MinWidth="100" >
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <Grid.Style>
                                    <Style>

                                    </Style>
                                </Grid.Style>

                                <TextBlock Text="{Binding Path=patientid}">
                                </TextBlock>
                            </Grid>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>
                <DataGridTemplateColumn Header="Last, First" SortMemberPath="name" Width="Auto" MinWidth="100" >
                    <DataGridTemplateColumn.CellTemplate>
                        <DataTemplate>
                            <Grid>
                                <Grid.Style>
                                    <Style>

                                    </Style>
                                </Grid.Style>
                                <TextBlock Text="{Binding Path=name}"></TextBlock>
                            </Grid>
                        </DataTemplate>
                    </DataGridTemplateColumn.CellTemplate>
                </DataGridTemplateColumn>

            </DataGrid.Columns>

        </DataGrid>

1 个答案:

答案 0 :(得分:2)

有点奇怪,但行有一个标题。这就是你所看到的。仅设置列标题的可见性将解决您的问题:

HeadersVisibility="Column"