Can you please tell me how to remove borders and merge cells from a DataGrid column?

    1 answer 1

    Override Template.

    <DataGrid>  <DataGrid.Columns>   <DataGridTextColumn Header="Дата" />   <DataGridTextColumn>    <DataGridTextColumn.HeaderTemplate>     <DataTemplate>      <Grid>       <Grid.Resources>        <Style TargetType="TextBlock">         <Setter Property="HorizontalAlignment" Value="Center" />         <Setter Property="Margin" Value="5 0 5 0" />        </Style>       </Grid.Resources>       <Grid.RowDefinitions>        <RowDefinition />        <RowDefinition />       </Grid.RowDefinitions>       <Grid.ColumnDefinitions>        <ColumnDefinition />        <ColumnDefinition />        <ColumnDefinition />       </Grid.ColumnDefinitions>       <TextBlock Grid.ColumnSpan="3" Text="Набор1" />       <TextBlock Grid.Row="1" Text="Зн1" />       <TextBlock Grid.Row="1" Grid.Column="1" Text="Зн2" />       <TextBlock Grid.Row="1" Grid.Column="2" Text="Зн3" />      </Grid>     </DataTemplate>    </DataGridTextColumn.HeaderTemplate>   </DataGridTextColumn>   <DataGridTextColumn>    <DataGridTextColumn.HeaderTemplate>     <DataTemplate>      <TextBlock Text="условие" Margin="0 0 5 0">       <TextBlock.LayoutTransform>        <RotateTransform Angle="270" />       </TextBlock.LayoutTransform>      </TextBlock>     </DataTemplate>    </DataGridTextColumn.HeaderTemplate>   </DataGridTextColumn>   <DataGridTextColumn>    <DataGridTextColumn.HeaderTemplate>     <DataTemplate>      <Grid>       <Grid.Resources>        <Style TargetType="TextBlock">         <Setter Property="HorizontalAlignment" Value="Center" />         <Setter Property="Margin" Value="5 0 5 0" />        </Style>       </Grid.Resources>       <Grid.RowDefinitions>        <RowDefinition />        <RowDefinition />       </Grid.RowDefinitions>       <Grid.ColumnDefinitions>        <ColumnDefinition />        <ColumnDefinition />       </Grid.ColumnDefinitions>       <TextBlock Grid.ColumnSpan="2" Text="Набор2" />       <TextBlock Grid.Row="1" Text="Зн1" />       <TextBlock Grid.Row="1" Grid.Column="1" Text="Зн2" />      </Grid>     </DataTemplate>    </DataGridTextColumn.HeaderTemplate>   </DataGridTextColumn>  </DataGrid.Columns> </DataGrid> 

    PS posted with mobile, maybe everything is crooked, I apologize.

    • khm you have something moved, it is not readable ... - PECHAPTER
    • We catch RowDataBound, we delete an unnecessary cell and does necessary stretched on two columns. e.Row.Cells.RemoveAt (1); e.Row.Cells [0] .ColumnSpan = 2; - MajorMeow 5:59 pm
    • I'm not even sure that this is what I need. I just don’t remember somewhere where I saw such an interface: a table, when you hover over a cell, a button appears right in this cell, there was something like copying to the clipboard chtoli ... So I wanted something like that to do. - PECHAPTER
    • Try to find a sample, so it will be easier to tell you. - MajorMeow