I'm currently working with Monotouch.Dialog and I have a big list of item.
I don't want to load all data immediately, so I implemented (on monodroid) a LoadMore method which load more data in my list when I scroll to the bottom of the list ( 20 element before the end, I LoadMore ).
So my question is, how can I implement an ScrollListener on my DialogControllerView do to the same thing on Monotouch ?
thx :)
Because uitableview is as subclass of uiscrollview, you can use uiscrollviewdelegate
this.TableView.Scrolled += (sender, e) => {};
i think this should work for you.
Related
.NET Maui CarouselView. In certain situations I want my app to take the user to the next card automatically. If I update CarouselView.Position or CarouselView.CurrentItem in code behind, it "jumps" to the next card immediately, no animation. Is it possible to imitate user's swipe? Or as a workaround, maybe somehow apply non-native-CarouselView animation manually to the CarouselView. Please advise.
The CarouselView contains a ScrollTo method that will animate the scroll for you. You either scroll to an index or a specific item.
Give your CarouselView a name in the XAML, and then in the code behind call the ScrollTo.
To scroll to an index:
carouselView.ScrollTo(6);
To scroll to a specific item:
var viewModel = BindingContext as MyViewModel;
var item = viewModel.Items.FirstOrDefault(m => m.Name == "TheBest");
carouselView.ScrollTo(item);
These methods have to be called from the code behind, so if you're using a MVVM approach, you'll need to fire an event or command from your VM for your code behind to act on.
For additional info, take a look at the ScrollTo method docs from Microsoft.
Is there a ScrollView event in xamarin that is triggered when the user forces scroll up and scroll is already at top? Many apps uses this as the "command" to update the page.
Currently, there is no PullToRefresh property or RefreshCommand for a ScrollView built into Xamarin.Forms. However, It does exist on ListView as shown in the docs, which you might be able to use instead depending on your needs.
Also, it does look like there is a PullToRefreshLayout opensource project created by James Montemagno you might be able to use to easily implement pull to refresh with a ScrollView, but it has been a while since it's last been updated.
You can use the Scrolled event handler. If the ScrollView is already positioned at the top of the contents and the user "pulls down" then Y amount will be either 0 or negative (I know this will work on Android and iOS, not sure about UWP and others).
scroll.Scrolled += (object sender, ScrolledEventArgs e) =>
{
if (e.ScrollY <= 0)
{
// scrolled when already at top of list
}
};
There is activity, fragment and a viewmodel binded to them both. Fragment has event which gets raised multiple times by Timer, delegate inside fragment is subscribed to that event and updates single UI element with value from a viewmodel.
Delegate:
private void OnTimerUpdate(object o, EventArgs e) {
this.Activity.RunOnUiThread(() => {TimerTextView.Text = ViewModel.TimerValue;});
}
It is called multiple times as planned, however ui element is not updating, unless I'm interacting with a View (e.g. scrolling).
Previously both ui element and delegate was inside activity and was working properly, however when I refactored it to have separate fragment, this happened.
Have you tried calling TimerTextView.Invalidate() after changing the text?
Found answer here. Which I thought was weird, but actually worked - set width and height of textview I'm updating to some values instead of 'wrap_conent'.
Quite simple Windows Phone question, but couldn't find anything about it searching the web.
I want to fire an event when a user has scrolled to the end of a ListBox (originally containing 100 items), so that I can asyncronously load some more items from my API.
IntelliSense didn't show any event I thought could be useful - perhaps somebody here can show me in the right direction on how I can have this type of functionality?
Kris
Using whats given here you can detect the end of scrolling and trigger an event on the code behind which will call for more items. Once you add them to your Observable Collection which will be bounded to your listbox's itemsource. The items will appear automatically. I hope it helps :)
I have a listbox of many richtextboxex in it.
Now I want to enable an auto scrolling feature for it.
I can't just do listBox.SelectedIndex++;in a timer or somthing, because then it will just go to the other richtextbox and I don't want that.
I'd like somthing more like this
sv.ScrollToVerticalOffset(sv.VerticalOffset + 5);
which works perfectly in scroll view, can I implement the same thing to a listbox?
Well I found what I was looking for
ScrollViewer sv = ((VisualTreeHelper.GetChild(listBox, 0) as FrameworkElement).FindName("ScrollViewer") as ScrollViewer);
sv.ScrollToVerticalOffset(sv.VerticalOffset + 0.004);
Thank you guys
If you use something like Linq To Visual Tree you can get at the ScrollViewer inside the ListBox and then call ScrollToVerticalOffset on that.
Yes you can. Here you should give the item index it automatically scrolls to the item
list.ScrollIntoView(object item);