3
votes

I've recently updated a Windows Phone 8 app to Windows Phone 8.1. I'm trying to add a <DatePicker /> control (newly available in Windows Phone 8.1) to the XAML but it's not available in my XAML.

I get the errors:

The name "DatePicker" does not exist in the namespace "http://schemas.microsoft.com/client/2007"

and

The type 'DatePicker' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.

and

The tag 'DatePicker' does not exist in XML namespace 'http://schemas.microsoft.com/winfx/2006/xaml/presentation'

However, if I create a new Windows Phone app the DatePicker is available there.

Also, I can create and add the DatePicker via the codebehind, just not in XAML.

I have checked and can confirm the project is targeting Windows Phone 8.1, and as far as I can see I am referencing the correct assembly:

enter image description here

What do I need to do to make the DatePicker available in XAML?

3

3 Answers

6
votes

You upgraded your project to a windows phone silverlight 8.1 app, not a windows phone windows runtime 8.1. The new DatePicker is only available for windows phone windows runtime 8.1. In a windows phone silverlight 8.1 app you will still need to use the DatePicker from the windows phone toolkit.

0
votes

You can use C# for that matter.

using Windows.UI.Xaml.Controls;

DatePicker is available within this namespace as mentioned on MSDN. Also make sure your XAML has following namespaces:

<Page
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:YourAppName"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:UI="using:Microsoft.Advertising.Mobile.UI"
    x:Class="YourAppName.MainPage"
    mc:Ignorable="d">

These are the basic namespaces required to format a WP8.1 app's XAML page. Try these if still not working:

  • Use Toolbox and drag and drop the DatePicker from the list. It will automatically add the missing namespaces.
  • After each edit, make sure you Rebuild the solution to reload the designer.

Hope this helps.

0
votes

Did you try working out with the sample code from msdn.

Please refer to the below sample for Windows Phone 7, hope this would work for WP 8.1.

http://www.geekchamp.com/articles/wp7-loopingselector-in-depth--part1-visual-structure-and-api

Hope it helps!