Automatic Scrolling as it receives the objects - c#

I have some pop up buttons on my scrollview. When hit play ,buttons pop up and if done manually scrolling is also supported. But what I am trying to bring is when my scene loads both my buttons and scrollview should work simultaneously i.e buttons popping up and scrollview getting scrolled as it receives the buttons. Any help would be appreciated. And thanks in advance.

If I get it right u need to scroll automatically each time an item is added to your scrollview.
U could put this in button click event handler:
scrollViewer.LineDown();
scrollViewer is in this case scrollviewer object it's self.
If you're using MVVM pattern, I suggest u to create a behavior class and put it there or via command attached to the button. The solution with command is easier, but dirty.

Related

button with 2 images and text in xamarin forms

I am trying to create a button with two images on it. One at left side and one at right side and text in center. After searching I got a button with image only so I wanted to know if it is posible to create a button as I described above in xamarin?
I am trying to create button like this and also I want to change arrow image on the button click to up arrow and down arrow. Is it posible in xamarin to create button like this or should I think about another option any idea?
You can't directly do this with the Button from Xamarin Forms as it doesn't support images yet.
From your requirement what you can do is create a horizontal stacklayout and add the images and a label to it. Also set a background color so that it would look like a button.
To make it work like a button, add a Gesture recognizer to the stack layout and add the tap gesture.
You can handle the event for tapping or bind it via command if you are using MVVM.

WPF ScrollViewer Changed Event fired automatically

As per requirement need in C# WPF application , We want to load Data on scrollViewer while moving Horizontal scroll bar.
As we have tried by scrollViewer_ScrollChanged event. But It fired automatically every time while loading of scrollViewer.
In our case we have one grid control inside scrollViewer.
Please help me, looking for positive reply.

Make control transparent to drag events during drag-and-drop

I have a ListView that acts as a drop target for drag and drop operations. When the list is empty, I place a TextBlock over top of it with a message informing users they can drag things there (both controls are contained in a single Grid cell to enable overlap). But... since the TextBlock is on top of the ListView, it intercepts the various events connected to drag and drop and prevents things from being dropped onto the message text itself.
I really don't want to add a drop handler to the TextBlock--is there any way I can simply make it "transparent" to drag and drop operations?
Something that just occurred to me while writing this which does work is to put the text below the list in the Z-order and then give the list a transparent background. But is this really the right way to achieve this? Ideally, there'd be a way to give the text one ZIndex for rendering, and a different one for hit testing.
Set IsHitTestVisible to False for TextBlock.

Only display complete items in a stackpanel

I have a slider which consists of grid of:
Scrollviewer
Stackpanel (the stackpanel is located inside the viewer)
The slider has 2 navigation buttons to browse trough the selected items.
But how can i only show complete items? Currently some buttons only get shown in half because there is no more space available. In the final version only 5 buttons should be shown at once. But if a certain event is fired more buttons will be visible for.
For example 1-5 are visible. If another button pops up only 2-6 should be visible.
The buttons inside the slider have to be created dynamically.
Does it make sense to stick with stack panel? Cause at the moment the buttons are static.
EDIT: When adding buttons dynamicly to the stackpanel how exactly does this work for already custom made buttons? I can add a normal button just fine but i wish to add the buttons already made below.
I believe the VirtualizingStackPanel (with virtualisation turned on as it is by default) can only perform item-based scrolling (as opposed to pixel-based scrolling). It might be worth trying swapping the StackPanel for a VirtualizingStackPanel to see if that fixes your problem.

In a WPF ListView how can I prevent auto scrolling?

I have a WPF ListView which currently scrolls everytime I click on an item which is only partially visible. How can I keep the control from scrolling that item into view (instead simply selecting the partially visible one)? This behavior is very annoying when doing a drag from this control.
Thanks.
Added: I am looking for a solution to keep the control itself from scrolling when contents are clicked that the control believes are not fully visible. Often this is by a few pixels and the scroll is not necessary.
The items scroll into view because the default behavior on list item click is to call BringIntoView(). You can add an event handler for the RequestBringIntoView event and catch it before it bubbles up from the ListViewItems to the ScrollViewer. In your handler, check the bounds of the sender against the visible region and if you decide that you don't need to scroll, set the event's Handled flag to true.
Since I'm currently on the road, I cannot try this, but have you tried playing around with CanContentScroll, and/or wrapping the scrollable content into a Panel, as suggested by the ScrollViewer Overview on MSDN?
In the worst case, you might want to replace the ListView's ItemsPanel by a hacked ScrollViewer with a "fuzz" factor, e.g. by capturing the RequestBringIntoView event.
have you tried this approach?
just as an addon, I don't know how much you know about the subject, but here is a good place to read more about it.
added:
I just found that you can prevent the mouse wheel of scrolling as well.

Categories