Closed GF-Huang closed 3 years ago
Thanks, @GF-Huang. Could you provide a repro project? Thanks.
@GF-Huang I used below code to scroll into line 21 of DataGrid
int rowindex = 20;
dataGrid.ScrollIntoView(dataGrid.Items[rowindex]);
It works well as:
Is that the same as your usage?
Did you use a custom group template?
Yes, my xaml code is:
<Window.Resources>
<Style x:Key="GroupHeaderStyle" TargetType="{x:Type GroupItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupItem}">
<Expander IsExpanded="True">
<Expander.Header>
<TextBlock Text="{Binding Path=Name}"/>
</Expander.Header>
<ItemsPresenter />
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</Window.Resources>
<Grid>
<DataGrid Name="dataGrid" Width="600" Height="250" HorizontalAlignment="Left" VerticalAlignment="Top">
<DataGrid.GroupStyle>
<GroupStyle ContainerStyle="{StaticResource GroupHeaderStyle}">
<GroupStyle.Panel>
<ItemsPanelTemplate>
<DataGridRowsPresenter/>
</ItemsPanelTemplate>
</GroupStyle.Panel>
</GroupStyle>
</DataGrid.GroupStyle>
</DataGrid>
<Button Content="Button" HorizontalAlignment="Left" Margin="226,325,0,0" VerticalAlignment="Top" Width="75" Click="Button_Click"/>
</Grid>
These make it works, thanks.
<GroupStyle.Panel>
<ItemsPanelTemplate>
<DataGridRowsPresenter/>
</ItemsPanelTemplate>
</GroupStyle.Panel>
Security issues and bugs should be reported privately, learn more via our responsible disclosure guidelines.
Problem description: DataGrid.ScrollIntoView not works when DataGrid is grouping
Actual behavior: DataGrid.ScrollIntoView not works when DataGrid is grouping
Expected behavior: DataGrid.ScrollIntoView works well when in grouping.
Minimal repro: