beesasoh
beesasoh

Reputation: 2135

Setting the GridView Selected item to none

I am developing windows 8.1 app using Xaml and c#, Windows 8.1 selectes the first list item when the list loads. How can i Change this so that the list has no selectedItem when it loads.

Upvotes: 2

Views: 1421

Answers (2)

Arctic Vowel
Arctic Vowel

Reputation: 1522

In my case, setting the SelectedIndex to -1 did not work. If you are populating your GridView from a CollectionViewSource, you have to insert this line in the GridView :

IsSynchronizedWithCurrentItem="False"

From MSDN

Selection behavior and CollectionViewSource

List controls that derive from Selector have a default selection behavior that depends on what the items source is (the type that's used for ItemsSource). If the items source is a CollectionViewSource instance, then the behavior in the selection control is that the selection will default to the current item. When the list is first displayed, the selection defaults to the first item as current item. If you don't want the first item to be selected in this case, set IsSynchronizedWithCurrentItem to false in the GridView.

Upvotes: 1

user3348652
user3348652

Reputation: 49

From MSDN documentation:

Use the SelectedIndex property to determine the index of the currently selected row in a >GridView control. You can also use this property to programmatically select a row in the >control. To clear the selection of a row, set this property to -1.

Source: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.selectedindex(v=vs.110).aspx

Upvotes: 3

Related Questions