Hi
I have a grid, which is bound to a simple BindingList, with time and status as the two variables, both strings. When I add to the underlying data I want the grid to scroll to the bottom of the data. I have the following code, which I thought would work, based on some of the posts I have read here, but I just can't get it to behave.
The grid sometimes shows the last item part way up the grid, with empty space below, sometimes as the only entry in the grid, i.e. at the top with loads more space below. I've posted the XAML for the grid too. Is there something I'm missing ??
If I have the MS WPF Datagrid I just need the following command and it works a treat: statusGrid.ScrollIntoView(statusGrid.Items[statusGrid.Items.Count - 1]);
Any help would be appreciated, thanks, Mike...
BTW I have v3.2 standard
Code:
public void Logger(string updateWith)
{
DateTime itisNow = DateTime.Now;
logthis.Add(new LogClass { LogTime = itisNow.ToString(), LogData = updateWith });
if (statusGrid.Items.Count > 8) //Only Scroll when more than 8 items are in the data. Remember grid is fixed size.
{
statusGrid.SelectedItems.Clear();
statusGrid.SelectedItem = statusGrid.Items[statusGrid.Items.Count - 1];
statusGrid.BringItemIntoView(statusGrid.SelectedItem);
statusGrid.SelectedItem = null;
}
}
<xcdg:DataGridControl x:Name="statusGrid" ItemsSource="{Binding}" ReadOnly="True" EditTriggers="None" SelectionMode="Single" NavigationBehavior="RowOnly" ItemScrollingBehavior="Immediate" Height="110" FontSize="10" Foreground="DarkOliveGreen" Background="Black" Grid.RowSpan="2" BorderThickness="0">
<xcdg:DataGridControl.Columns>
<xcdg:Column FieldName="LogTime" ReadOnly="True" ShowInColumnChooser="False" Title="Time" />
<xcdg:Column FieldName="LogData" IsMainColumn="True" ReadOnly="True" ShowInColumnChooser="False" Title="LogEntry" />
</xcdg:DataGridControl.Columns>
<xcdg:DataGridControl.Resources>
<Style x:Key="{x:Type xcdg:ScrollTip}" TargetType="xcdg:ScrollTip">
<Setter Property="HorizontalAlignment" Value="Right" />
<Setter Property="VerticalAlignment" Value="Center" />
</Style>
</xcdg:DataGridControl.Resources>
<xcdg:DataGridControl.View>
<xcdg:TableView ShowFixedColumnSplitter="False" ColumnStretchMode="Last" ShowRowSelectorPane="False" IsAlternatingRowStyleEnabled="False" UseDefaultHeadersFooters="False" ShowScrollTip="True">
<xcdg:TableView.FixedHeaders>
<DataTemplate>
<xcdg:ColumnManagerRow AllowSort="False" AllowColumnReorder="False" AllowColumnResize="False" AllowAutoFilter="False" />
</DataTemplate>
</xcdg:TableView.FixedHeaders>
<xcdg:TableView.Theme>
<xcdg:AeroNormalColorTheme />
</xcdg:TableView.Theme>
</xcdg:TableView>
</xcdg:DataGridControl.View>
</xcdg:DataGridControl>