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

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.

Related

DataBound ComboBox not changing when an item is selected

I have a DataBound ComboBox and everything on it works great. But when I select an item in the list, the SelectedValue changes correctly but the text that gets displayed stays on the first item.
There is no code behind this, I added the DataBinding in the form builder.
It was a dumb mistake.
I had the SelectedValue set in the DataBinding Menu.

Scroll automatically to a control inside scrollviewer

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?

Silverlight Usercontrol in Datagrid does not fire the CellEditEnded event

I have a UserControl that is displaying in a DataGrid. It contains a DatePicker and a Button that opens a Popup control where the user makes a selection that once selected populates a textblock with the result. The DatePicker is the only object that if changed will set off the CellEditEnded event. How can I get the popup controls selectionChanged event to tell the Datagrid that the cell has done as edit?
Turns out I was putting the UserControl inside the CellTemplate when I needed to put something else in that for display and my UC in the CellEditingTemplate. Now it fires as it should. I missed something simple and I should not have. Hope this helps someone else.

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 do you keep a listview row highlighted after its activated?

I have an application I'm working on that uses listviews. When you select a row from the list view it becomes highlighted, however when I double click on it to activate the listview item it is no longer highlighted. How would I get the listview item to stay highlighted upon activation, is this possible? Thanks.
It sounds like you are somehow losing focus from the control. If that logic is correct, then you can set the listview's .HideSelection = False property to retain the visual selection when the control loses focus.