AlexDuncan
AlexDuncan

Reputation: 95

The type or namespace name 'ListPicker' does not exist in the namespace 'Microsoft.Phone.Controls'?

So I've been tinkering with some code, which I kinda regret, originally the problem was the Microsoft.Phone.Controls was in the wrong path directory which I've removed and re-added to the references successfully.

I'm getting a new error, and it seems just to be the listpicker element which it doesn't like.

enter image description here

Upvotes: 0

Views: 4396

Answers (1)

Josh Earl
Josh Earl

Reputation: 18351

I posted this in an update on your previous question, but I'll move it here. :)

The ListPicker is a control in the Silverlight Toolkit for Windows Phone, which is an add in set of controls published by Microsoft.

When you add a control to the page, you need to add a reference to the .dll to the XAML page and map it to a prefix that will tell Visual Studio where to find the control:

<phone:PhoneApplicationPage x:Class="MyApp.MainPage"
                            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                            xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
                            xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
                            xmlns:controls="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls"
                            xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit">

Note the toolkit prefix.

Now you can add a control like this:

<toolkit:ListPicker></toolkit:ListPicker>

If those items are set up correctly, you might also need to check if the .dll was "blocked" when you downloaded it. Browse to the .dll in Explorer, then right click and look at the bottom for a button called Unblock. If it's there, click it.

The references in the XAML can be tricky to set up. There's a sample app available for the toolkit that can be helpful.

Upvotes: 4

Related Questions