Replies: 1 comment
-
private void OnDataContextSet(object sender, EventArgs e)
{
if (UIType != PluginUI.UIType.Basic || !(sender is DataGrid)) return;
dataGrid = (DataGrid)sender;
if (dataGrid.DataContext != null)
{
var dataContext = ((ViewModels.BasicUIViewModel)dataGrid.DataContext).BasicUIGrid;
dataContext.CollectionChanged += ScrollToLast;
}
}
private void ScrollToLast(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
// Only trigger on adds.
if (e.Action != System.Collections.Specialized.NotifyCollectionChangedAction.Add || UIType != PluginUI.UIType.Basic || dataGrid == null || !(sender is ObservableCollection<object>))
return;
var dataContext = (ObservableCollection<object>)sender;
Avalonia.Threading.Dispatcher.UIThread.InvokeAsync(() =>
{
dataGrid.ScrollIntoView(dataContext[dataContext.Count - 1], null);
});
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
因为我的DataGrid是动态更新的,我想在他数据更新的时候自动滑动到最底部,这个现在有办法实现吗
Beta Was this translation helpful? Give feedback.
All reactions