0
votes

I am new to windows 8 phone application development.

I want implement listpicker in my application. I have gone through few post and installed Nuget package. After installing, I straight a way went to XAML and added the below code

< toolkit:ListPicker Header="Default" Grid.Row="1" x:Name="defaultPicker" />

I am getting a blue zig-zag line underneath the code(Means there is some error). Can any one help me in implementingthe listpicker functionality. It will be so helpful if you can explain with sample code.

3
did you check the error tab in visual studio? Normally you should find there a description message of the error you're getting.disklosr

3 Answers

1
votes

You missed the namespace declaration of the WPtoolkit assembly. In your XAML namespaces declaration you should have this line:

xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
1
votes

Did you add the namespace in the header

xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
0
votes

Two solution:

  • use mvvm pattern Create ViewModel. Create binding.

    private List _myList;

    public List MyList { get { return _myList; } set { _myList= value; this.RaisePropertyChanged("MyList"); } }

public YourViewModel(){ MyList = new List(); MyList.add("TOTO"); }

Bind your listPicker.

  • use code behind

Set the name of your listPicker

<toolkit:ListPicker x:Name="myList" Header="Default" Grid.Row="1" x:Name="defaultPicker" />

In your constructor.

List<string> s = new List<string>();
s.add("TOTO");
myList.itemSource = s;