Esempio n. 1
0
        private void ScrollToBottomButton_OnClick(object sender, EventArgs e)
        {
            var _ = OnPressedCachedImage(ScrollToBottomButton);

            object last = MessagesListBox.ItemsSource.Cast <object>().LastOrDefault();

            if (last is null)
            {
                return;
            }

            LoadPreviousMessagesButton.IsVisible = LoadPreviousMessagesButton.IsEnabled = false;

            MessagesListBox.ScrollTo(last, ScrollToPosition.Center, (e as ScrollToBottomEventArgs)?.Animated ?? true);
        }
Esempio n. 2
0
        private void LoadPreviousMessagesButton_OnClicked(object sender, EventArgs e)
        {
            object scrollLock = MessagesListBox.ItemsSource.Cast <object>().FirstOrDefault();

            if (scrollLock is null)
            {
                return;
            }

            if (BindingContext is ActiveConvoViewModel vm)
            {
                vm.LoadPreviousMessages().ContinueWith(_ =>
                {
                    Device.BeginInvokeOnMainThread(() =>
                    {
                        LoadPreviousMessagesButton.IsVisible = LoadPreviousMessagesButton.IsEnabled = false;
                        MessagesListBox.ScrollTo(scrollLock, ScrollToPosition.Start, false);
                    });
                });
            }
        }