Scroll automatically to a control inside scrollviewer - xaml

I have a scrollviewer in page which shows data vertically, and it contains controls like grid, stackpanel and listbox.
Listbox contains items with expanderview. On click of expander view header it expands, I just want that whenever it expands its content get visible in page. Means i have to automatically change scroll position and make visible a Listbox selected control.
Is there any way?

There is a way to manage it Programatically with use of Timer. When the timer is triggerd, we call the timer_Tick event handler, which scrolls to the current index and marks it as selected, and then updates the index. After the last item is highlighted the index is reset to the first item. You can find useful sample here Auto-scrolling ListBox for Windows Phone

You need to calculate the offset where you want to scroll to, and then use ScrollToVerticalOffset(your_offset_value) method.
Have a look over here : How to use ScrollViewer.ScrollToVerticalOffset?

Related

Object reference in vb. Net when clicking icon

I have a panel that fills with icons of characters. I have a second panel I would like to fill with icons from which character is selected. What is the best way to know which character was selected? Both panels are flow layout panels. I can hover over the character and display the name but I need a good way to reference which character is clicked. The entire object is a user control and another object that retrieves the champion icons to fill the first panel. Thank you.
You need to handle the form.KeyPress event.
Control.KeyPress Event
Examine the KeyEventArgs and go from there.

Show hide content in List item in Windows Phone 8.1

I'm developing WP8.1 app in that I need to show some content with show/hide functionality. First 2 lines will be displayed and once clicking on that item the remaining content should expanded and display. How we can achieve this in WP8.1
In order to show or hide you have to go for binding.
And to expand the content, have your DataTemplate as StackPanel and set the Height property of TextBlock (through binding) with the value that is needed to display two lines.
And on tap of the item, just get the selectedItem instance and Increase the height property or set to auto
To know about binding see here http://msdn.microsoft.com/en-us/library/windows/apps/cc278072(v=vs.105).aspx
you can use visibility and collapsed
like that
myimage. visibility =visibility.visible;
you can control with this way

Is control location relative to visible area of form when form has scroll bar?

I have a VB.NET form that dynamically creates a set of controls. If there are too many controls to view on the form, the form will show a scroll bar. (It is an autoscroll form.)
The user can scroll down and click a button which causes the form to change dramatically. It destroys all controls and draws new ones based on user input.
I've noticed that if the user is scrolled to the bottom of the form and click the button, when I destroy and create new controls they aren't located where I want them. It seems to put them relative to the visible portion of the form rather than the top of the top.
Example:
checkbox1.top = 50
checkbox1.left = 15
If the scrollbar is all the way at the bottom, the checkbox should be placed above the visible part of the form. Instead, it is drawn 50 pixels from the top of what I can see.
Please help. How do I make it place the control at an absolute location, rather than being relative to the current position of the scrollbar?
You have to compensate for the scroll position of the container control.
If a panel, then it would look like this:
checkbox1.Top = Panel1.AutoScrollPosition.Y + 50
Alternatively, you could just use a FlowLayoutPanel control, which would handle the placement of the controls for you.

Enable scrolling on disabled listview in vb.net

when i disable a listview in vb.net by setting Enabled=False, the scrolling is disabled too so i can't see all the items in the list. Is there a way to disable user interaction on the list but preserve the scrolling so that the user can't select any item but can drag the scrollbars?
Are you sure you want to do this? You will end up with a list view that looks like it should function normally, but users will not be able to select any items.
This could potentially be very confusing.
If this is really what you want (and I advise against it), you could add a handler to the ItemSelectionChanged event that deselects whichever item has just been selected.

how to disable the default selection in listview when you navigate to it

I have two list views in a scene (listview1 and listview2, contents of listview2 depends on the selecteditem on listview1) and when I navigate to the scene I want the first item in listview1 to be selected and the details be displayed in the other listview (listview2) but I do not want any item in the listView2 selected by default.
What i am observing is that the first item in listView2 is also selected and that is causing selectionchanged event to be triggered for listview2 (which I want to be triggered only if the user explicitly selects it)
No need for workarounds.
Just set IsSynchronizedWithCurrentItem="False" in your ListView.
This also works for GridViews.
selectionchanged events will be triggered and cannot be stopped. But it can be bypassed (using a flag) in the code behind.
If ListView is bound to CollectionViewSource, CollectionViewSource sets the first items as selected.
If ListView is bound to regular Collection, no items will be selected automatically.
This is because you set the event handler of list view 1 & 2 by XAML, maybe.
If you set the data source and selected item first, then,
set the event handler by your code behind, it works well, I think.