0
votes
   long stdid;
    string stdname;


    public long studentId
    {
        get { return stdid; }
        set { stdid = value; }
    }

    public string studentName
    {
        get { return stdname; }
        set { stdname = value; }
    }

how do I show my listpikcer with by default selected item "SELECT", my listpicker is binded with,

ItemsSource = "{Binding}"

I have not added items manually in listpicker, items come from class, so, how to solve it?

1
okay share your class definitionA.K.
@AmanKhandelwal see my edited code..thanks!!Viraj Shah

1 Answers

2
votes

Create a new List of your class type

List<MyClass> myList=new List<MyClass>();

and add one item of your class type somewhat like this:

myList.Add(new MyClass(){studentName="Please Select, StudentId=0"});

now add the items of your class list in this new list

foreach(var item in oldList)
{
myList.add(item);
}

after this loop assign myList as the itemsource to the listpicker and check.

listpicker.ItemSource=myList;
listpicker.SelectedIndex=0;