EN
Il contenuto non è disponibile nella lingua di destinazione, ma solo in inglese.

How to extend the Search experience for Windows Phone 8

Applies to: Windows Phone 8 and Windows Phone Silverlight 8.1 | Windows Phone OS 7.1

 

This topic shows you how to extend search for Windows Phone by creating a Search extensibility app. When you’re finished with that, you can use the app to test quick cards, such as a product card, a place card, or a movie card. The app featured in this topic extracts parameters from the deep link URI and then displays them on an app page. For more information about extending the search experience, see Search extensibility for Windows Phone 8.

TipTip:

The code featured in this topic is from the Quick Card Sample.

This topic contains the following sections.

 

By following the steps in this topic, you’ll modify or create the following files:

  • WMAppManifest.xml: Modify the app manifest file to specify the search extensions corresponding to the app.

  • Extensions\Extras.xml: Create this file to specify the app title and caption that appears in the apps pivot page of the corresponding quick card.

  • App.xaml: Modify this file to specify the URI mapping from the quick card deep link to the quick card target page.

  • App.xaml.cs: Modify this file to enable URI mapping in the app.

  • Model\QuickCardUriParameters.cs: Create this class file to represent a parameter in a deep link URI. This class implements theINotifyPropertyChanged interface.

  • ViewModel\QuickCardViewModel.cs: Create this class file to represent the ViewModel of the quick card target page. This class extracts the parameters from the deep link URI and implements the INotifyPropertyChanged interface.

  • QuickCardTargetPage.xaml: Create the quick card target page and modify the XAML code to present the parameters from the deep link URI. With respect to the MVVM pattern, this page is the view.

  • QuickCardTargetPage.xaml.cs: Modify this page to create the ViewModel object and load the parameters into the ViewModel when the page loads.

  • MainPage.xaml: Modify this page to present text for a standard app launch. This page isn’t launched by Search extensibility.

The app created in this topic uses a Model-View-ViewModel (MVVM) pattern. For another example of an MVVM app, see Implementing the Model-View-ViewModel pattern for Windows Phone 8.

In this section, you create the app and modify the app manifest file to specify the search extensions that are relevant to your app. In this example, three extensions are specified to demonstrate the three types of quick cards. For a list of all extensions, see Search registration and launch reference for Windows Phone 8.

To configure the app manifest

  1. Open the Windows Phone SDK and create a new project using the Windows Phone App  template.

  2. After the project loads, open the app manifest file: in Solution Explorer, expand Properties to locate the WMAppManifest.xml file. Then right-click the file name, click Open with, and select XML (Text) Editor.

  3. In WMAppManifest.xml, add the following code to the App element, below the Tokens element.

        <Extensions>
          <!-- Production extensions, for products: video games -->
          <Extension
            ExtensionName="Bing_Products_Video_Games"
            ConsumerID="{5B04B775-356B-4AA0-AAF8-6491FFEA5661}"
            TaskID="_default"
            ExtraFile="Extensions\\Extras.xml" />
    
          <!-- Production extensions, for movies. -->
          <Extension
            ExtensionName="Bing_Movies"
            ConsumerID="{5B04B775-356B-4AA0-AAF8-6491FFEA5661}"
            TaskID="_default"
            ExtraFile="Extensions\\Extras.xml" />
          
          <!-- Production extensions, for places: travel, food, and dining. -->
          <Extension
            ExtensionName="Bing_Places_Food_and_Dining"
            ConsumerID="{5B04B775-356B-4AA0-AAF8-6491FFEA5661}"
            TaskID="_default"
            ExtraFile="Extensions\\Extras.xml" />
        </Extensions>
    
    

    This code adds three extensions, one for each type of quick card: product card, movie card, and place card. A quick card that isn’t associated with these extensions won’t surface this app in the apps pivot pages corresponding to the quick card. For a complete list of search extensions, see Search registration and launch reference for Windows Phone 8.

In this section, you create the Extras.xml file and specify the app title and caption that appears in the apps pivot page of the corresponding quick card.

To create the Extras.xml file

  1. In Solution Explorer, right-click your project and select Add, then New Folder.

  2. Name the new folder Extensions.

  3. In Solution Explorer, right-click the Extensions folder and select Add, then New Item.

  4. In the Add New Item window, select XML File and name the file Extras.xml. Then click Add.

  5. In Extras.xml, replace the code with the following.

    <?xml version="1.0" encoding="utf-8" ?>
    <ExtrasInfo>
    
      <!-- App title (used only in Windows Phone OS 7.1 -->
      <AppTitle>
        <default>Display URI Parameters</default>
      </AppTitle>
    
      <!-- Search-related captions -->
      <Consumer ConsumerID="{5B04B775-356B-4AA0-AAF8-6491FFEA5661}">
    
        <!-- Products caption for video games -->
        <ExtensionInfo>
          <Extensions>
            <ExtensionName>Bing_Products_Video_Games</ExtensionName>
          </Extensions>
          <CaptionString>
            <default>Product URI Details</default>
          </CaptionString>
        </ExtensionInfo>
    
        <!-- Movies caption -->
        <ExtensionInfo>
          <Extensions>
            <ExtensionName>Bing_Movies</ExtensionName>
          </Extensions>
          <CaptionString>
            <default>Movie URI Details</default>
          </CaptionString>
        </ExtensionInfo>
    
        <!-- Places caption for food and dining -->
        <ExtensionInfo>
          <Extensions>
            <ExtensionName>Bing_Places_Food_and_Dining</ExtensionName>
          </Extensions>
          <CaptionString>
            <default>Place URI Details</default>
          </CaptionString>
        </ExtensionInfo>
      </Consumer>
    </ExtrasInfo>
    
    

    This code specifies how the app title and captions appears in the apps pivot page, depending on the type of quick card. In the apps pivot page for all quick cards, the app title will be Display deep link URI Parameters. The caption will be different, depending on the type of quick card:

    • For product cards (associated with the Bing_Products_Electronics extension): Product URI Details

    • For movie cards (quick cards associated with the Bing_Movies extension): Movie URI Details

    • For place cards (associated with the Bing_Places_Food_and_Dining extension): Place URI Details

In this section, you map the URI from the quick card deep link to the quick card target page. You accomplish this by creating a quick card URI mapper class and assigning it to the application frame in the app.xaml.cs file. Note that the quick card target page is created later in this topic, in the section Creating the quick card target page.

The URI mapper class created in this section modifies the URI by replacing “SearchExtras” with the name of the page in your app that is to be launched. It also re-encodes each of the URI parameter values, handling any special characters that could be sent from the quick cards.

To create the URI mapper class

  1. In Solution Explorer, right-click your project and select Add, then New Item.

  2. In the Add New Item window, select Class and name the file QuickCardUriMapper.cs. Then click Add.

  3. In QuickCardUriMapper.cs, replace the list of directives with the following.

    using System;
    using System.Windows.Navigation;
    using System.Net;
    
    
  4. In QuickCardUriMapper.cs, update the class statement so that it inherits from the UriMapperBase class, as follows:

    public class QuickCardUriMapper : UriMapperBase
    
    
  5. In the QuickCardUriMapper class, add the following code. This code re-encodes each of the deep link URI parameter values. The destination page of the URI is determined by the static string named TargetPageName.

    // Navigation destination. 
    private static string TargetPageName = "QuickCardTargetPage.xaml";
    private string tempUri;
    
    public override Uri MapUri(Uri uri)
    {
        tempUri = uri.ToString();
                
        // Parse URI when launched by from a quick card.
        if (tempUri.Contains("/SearchExtras"))
        {
            // Decode all characters in the URI.
            tempUri = HttpUtility.UrlDecode(tempUri);
    
            // Create a new URI for product cards.
            if (tempUri.Contains("Bing_Products"))
            {
                return GetProductCardUri(tempUri);
            }
    
            // Create a new URI for place cards.
            if (tempUri.Contains("Bing_Places"))
            {
                return GetPlaceCardUri(tempUri);
            }
    
            // Create a new URI for movie cards.
            if (tempUri.Contains("Bing_Movies"))
            {
                return GetMovieCardUri(tempUri);
            }
        }
    
        // Immediately return the URI when it isn’t related to Search extensibility.
        return uri;
    }
    
    // Return a parsed Product Card URI.
    private Uri GetProductCardUri(string uri)
    {
        // Extract parameter values from URI.
        string ProductNameValue = GetURIParameterValue("ProductName=",uri);
        string CategoryValue = GetURIParameterValue("Category=",uri);
    
        // Create new URI.
        string NewURI = String.Format("/{0}?ProductName={1}&Category={2}", 
                                TargetPageName, ProductNameValue, CategoryValue);
    
        return new Uri(NewURI, UriKind.Relative);
    }
    
            
    // Return a parsed Place Card URI.
    private Uri GetPlaceCardUri(string uri)
    {
        // Extract parameter values from URI.
        string PlaceNameValue = GetURIParameterValue("PlaceName=", uri);
        string PlaceLatitudeValue = GetURIParameterValue("PlaceLatitude=", uri);
        string PlaceLongitudeValue = GetURIParameterValue("PlaceLongitude=", uri);
        string PlaceAddressValue = GetURIParameterValue("PlaceAddress=", uri);
        string CategoryValue = GetURIParameterValue("Category=", uri); 
    
        // Create new URI.
        string NewURI = String.Format("/{0}?PlaceName={1}&PlaceLatitude={2}&PlaceLongitude={3}&PlaceAddress={4}&Category={5}", 
                                TargetPageName, PlaceNameValue, PlaceLatitudeValue, PlaceLongitudeValue, PlaceAddressValue, CategoryValue);
    
        return new Uri(NewURI, UriKind.Relative);       
    }
    
    // Return a parsed Movie Card URI.
    private Uri GetMovieCardUri(string uri)
    {
        // Extract parameter values from URI.
        string MovieNameValue = GetURIParameterValue("MovieName=", uri);
        string CategoryValue = GetURIParameterValue("Category=", uri);
    
        // Create new URI.
        string NewURI = String.Format("/{0}?MovieName={1}&Category={2}",
                    TargetPageName, MovieNameValue, CategoryValue);
    
        return new Uri(NewURI, UriKind.Relative);
    }
    
    
    // This method extracts the string values that correspond to URI parameters from a quick card.
    private string GetURIParameterValue(string parameteridentifier, string uri)
    {
        string tempValue = "";
    
        // If the parameter exists in the string, extract the corresponding parameter value.
        if (uri.Contains(parameteridentifier))
        {
            string subUri; 
    
            // Extract the characters that contain and follow the parameter identifier.
            subUri = uri.Substring(uri.LastIndexOf(parameteridentifier));
    
            // Remove the parameter identifier from the substring.
            subUri = subUri.Replace(parameteridentifier, "");
                    
            // Obtain the position of the next parameter in the substring.
            int nextParameterPosition = FindNextParameter(subUri);
    
                    
            if (nextParameterPosition < int.MaxValue)
            {
                // Remove the characters that contain and follow the next parameter.
                tempValue = subUri.Substring(0, nextParameterPosition);
            }
            else
            {
                // No more parameters follow in the string. 
                tempValue = subUri;
            }
    
            // Encode the parameter values to help prevent issues in the URI.
            tempValue = HttpUtility.UrlEncode(tempValue);
        }
            
        return tempValue;
    }
    
    // Returns the string position of the next URI parameter, if applicable.
    private int FindNextParameter(string subUri)
    {
        int lowestPosition = int.MaxValue;
        int tempPosition;
    
        tempPosition = subUri.IndexOf("&ProductName");
        if ((tempPosition > -1) && (tempPosition < lowestPosition)) lowestPosition = tempPosition;
    
        tempPosition = subUri.IndexOf("&Category");
        if ((tempPosition > -1) && (tempPosition < lowestPosition)) lowestPosition = tempPosition;
    
        tempPosition = subUri.IndexOf("&PlaceName");
        if ((tempPosition > -1) && (tempPosition < lowestPosition)) lowestPosition = tempPosition;
    
        tempPosition = subUri.IndexOf("?PlaceName");
        if ((tempPosition > -1) && (tempPosition < lowestPosition)) lowestPosition = tempPosition;
    
        tempPosition = subUri.IndexOf("&PlaceLatitude");
        if ((tempPosition > -1) && (tempPosition < lowestPosition)) lowestPosition = tempPosition;
    
        tempPosition = subUri.IndexOf("&PlaceLongitude");
        if ((tempPosition > -1) && (tempPosition < lowestPosition)) lowestPosition = tempPosition;
    
        tempPosition = subUri.IndexOf("&PlaceAddress");
        if ((tempPosition > -1) && (tempPosition < lowestPosition)) lowestPosition = tempPosition;
    
        tempPosition = subUri.IndexOf("&MovieName");
        if ((tempPosition > -1) && (tempPosition < lowestPosition)) lowestPosition = tempPosition;
    
        return lowestPosition;
    }
    
    

To assign the URI mapper to the application frame

  • In App.xaml.cs, add the following code to the InitializePhoneApplication method. Note that you may need to expand the code region titled “Phone application initialization” to locate the method.

    // Assign the quick card URI mapper class to the application frame.
    RootFrame.UriMapper = new QuickCardUriMapper();
    
    

    This code assigns the QuickCardUriMapper class to the UriMapper property of the application frame. Don’t modify any of the existing code in the InitializePhoneApplication method; add only the UriMapper assignment, as shown in the following example.

    private void InitializePhoneApplication()
    {
        if (phoneApplicationInitialized)
            return;
    
        // Create the frame but don't set it as RootVisual yet; this allows the splash
        // screen to remain active until the application is ready to render.
        RootFrame = new PhoneApplicationFrame();
        RootFrame.Navigated += CompleteInitializePhoneApplication;
    
        // Assign the quick card URI mapper class to the application frame.
        RootFrame.UriMapper = new QuickCardUriMapper();
    
        // Handle navigation failures
        RootFrame.NavigationFailed += RootFrame_NavigationFailed;
    
        // Ensure we don't initialize again
        phoneApplicationInitialized = true;
    }
    

In this section you create a data model that represents a parameter from a quick card in the deep link URI. This class is used for binding to elements in the UI. For a full list of the parameters that correspond to each quick card, see Search registration and launch reference for Windows Phone 8.

To create the data model

  1. In Solution Explorer, right-click your project and select Add, then New Folder.

  2. Name the new folder Model.

  3. In Solution Explorer, right-click the Model folder and select Add, then New Item.

  4. In the Add New Item window, select Code File and name the file QuickCardUriParameter.cs. Then click Add.

  5. In QuickCardUriParameter.cs, add the following code.

    using System.ComponentModel;
    
    namespace QuickCardExample.Model
    {
        // Represents a parameter from a quick card in an deep link URI
        public class QuickCardUriParameter : INotifyPropertyChanged
        {
            // The parameter name
            private string _paramName;
            public string ParamName
            {
                get {return _paramName;}
                set
                {
                    if (_paramName != value)
                    {
                        _paramName = value;
                        NotifyPropertyChanged("ParamName");
                    }
                }
            }
    
            // The parameter value
            private string _paramValue;
            public string ParamValue
            {
                get {return _paramValue;}
                set
                {
                    if (_paramValue != value)
                    {
                        _paramValue = value;
                        NotifyPropertyChanged("ParamValue");
                    }
                }
            }
    
            // Class constructor
            public QuickCardUriParameter(string pName, string pValue)
            {
                _paramName = pName.Trim();
    
                if (_paramName == "Category")
                {
                // Place multiple categories on new lines.
                    _paramValue = pValue.Replace(",",",\n");
                }
                else
                {
                    _paramValue = pValue;
                }
            }
    
            #region INotifyPropertyChanged Members
    
            public event PropertyChangedEventHandler PropertyChanged;
    
            // Used to notify that a property changed
            private void NotifyPropertyChanged(string propertyName)
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
                }
            }
    
            #endregion
        }
    }
    
    

    This class consists of properties for the parameter name and value, a constructor that accepts the name and value, and the INotifyPropertyChanged members.

In this section, you create the ViewModel that corresponds to the quick card target page, QuickCardTargetPage.xaml. The ViewModel is responsible for extracting the URI parameters from the quick card.

To create the ViewModel

  1. In Solution Explorer, right-click your project and select Add, then New Folder.

  2. Name the new folder ViewModel.

  3. In Solution Explorer, right-click the ViewModel folder and select Add, then New Item.

  4. In the Add New Item window, select Code File and name the file QuickCardTargetPageViewModel.cs. Then click Add.

  5. In QuickCardTargetPageViewModel.cs, add the following code.

    using System.ComponentModel;
    using System.Collections.ObjectModel;
    using System.Collections.Generic;
    
    // Reference the data model.
    using QuickCardExample.Model;
    
    namespace QuickCardExample.ViewModel
    {    
        public class QuickCardTargetPageViewModel: INotifyPropertyChanged
        {
            // Observable collection for the deep link URI parameters.
            private ObservableCollection<QuickCardUriParameter> _QuickCardUriParameters;
            public ObservableCollection<QuickCardUriParameter> QuickCardUriParameters
            {
                get {return _QuickCardUriParameters;}
                set
                {
                    if (_QuickCardUriParameters != value)
                    {
                        _QuickCardUriParameters = value;
                        NotifyPropertyChanged("QuickCardUriParameters");
                    }
                }
            }
    
            // Class constructor.
            public QuickCardTargetPageViewModel()
            {
                // Create observable collection object.
                QuickCardUriParameters = new ObservableCollection<QuickCardUriParameter>();
            }
    
            // Load parameters from quick page; extract from the NavigationContext.QueryString
            public void LoadUriParameters(IDictionary<string,string> QueryString)
            {
                // Clear parameters in the ViewModel.
                QuickCardUriParameters.Clear();
    
                // Loop through the quick card parameters in the deep link URI.
                foreach (string strKey in QueryString.Keys)
                {
                    // Set default value for parameter if no value is present.
                    string strKeyValue = "<no value present in URI>";
    
                    // Try to extract parameter value from URI.
                    QueryString.TryGetValue(strKey, out strKeyValue);
    
                    // Add parameter object to ViewModel collection.
                    QuickCardUriParameters.Add(new QuickCardUriParameter(strKey, strKeyValue));
                }
            }
    
            #region INotifyPropertyChanged Members
    
            public event PropertyChangedEventHandler PropertyChanged;
    
            // Used to notify that a property has changed.
            private void NotifyPropertyChanged(string propertyName)
            {
                if (PropertyChanged != null)
                {
                    PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
                }
            }
            #endregion
        }
    }
    
    

    In the LoadUriParameters method, the ViewModel extracts the parameters from the deep link URI and loads them into an observable collection of type QuickCardUriParameter.

In this section, you create the quick card target page. This is the page that is launched from a quick card via the deep link URI. With respect to the MVVM pattern, this page is the view.

To create the quick card target page

  1. In Solution Explorer, right-click your project and select Add, then New Item.

  2. In the Add New Item window, select Windows Phone Portrait Page and name the file QuickCardTargetPage.xaml. Then click Add.

  3. In QuickCardTargetPage.xaml, replace the grid named LayoutRoot with the following code.

        <!--LayoutRoot is the root grid where all page content is placed-->
        <Grid x:Name="LayoutRoot" Background="Transparent">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
    
            <!--TitlePanel contains the name of the app and page title-->
            <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
                <TextBlock 
                    x:Name="ApplicationTitle" 
                    Text="QUICK CARD EXAMPLE" 
                    Style="{StaticResource PhoneTextNormalStyle}"/>
                <TextBlock 
                    x:Name="PageTitle" 
                    Text="URI details" 
                    Margin="9,-7,0,0" 
                    Style="{StaticResource PhoneTextTitle1Style}"/>
            </StackPanel>
     
            <!--ContentPanel contains ListBox and ListBox ItemTemplate.-->
            <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
                <ListBox x:Name="paramsListBox" Margin="0,0,-12,0" ItemsSource="{Binding QuickCardUriParameters}" >
                    <ListBox.ItemTemplate>
                        <DataTemplate>
                            <StackPanel >
                                <TextBlock 
                                    Text="{Binding ParamName}" 
                                    TextWrapping="Wrap" 
                                    Style="{StaticResource PhoneTextExtraLargeStyle}"/>
                                <TextBlock 
                                    Text="{Binding ParamValue}" 
                                    TextWrapping="Wrap" 
                                    Margin="12,-6,12,0" 
                                    Style="{StaticResource PhoneTextAccentStyle}"/>
                            </StackPanel>
                        </DataTemplate>
                    </ListBox.ItemTemplate>
                </ListBox>
            </Grid>
        </Grid>
    
    

    In this page, a ListBox control is bound to observable collection in the ViewModel, named QuickCardUriParameters. Inside the ListBox, two TextBlock controls are bound to each parameter in the observable collection. One TextBlock control binds to the ParamName property, another TextBlock control binds to the ParamValue property.

  4. In the code-behind file for the quick card target page, QuickCardTargetPage.xaml.cs, add the following directive to the top of the page.

    // Reference the ViewModel.
    using QuickCardExample.ViewModel;
    
    
  5. In QuickCardTargetPage.xaml.cs, add the following code to the class constructor after the InitializeComponent() call.

                // Create the ViewModel object.
                this.DataContext = new QuickCardTargetPageViewModel();
    
                // Create event handler for the page Loaded event.
                this.Loaded += new RoutedEventHandler(QuickCardTargetPage_Loaded);
    
    
    

    This code creates a new QuickCardTargetPageViewModel object and assigns it to the data context of the page. This code also creates configures an event handler for the page Loaded event.

  6. In QuickCardTargetPage.xaml.cs, add the following code to the page class.

            // A property for the ViewModel.
            QuickCardTargetPageViewModel ViewModel
            {
                get { return (QuickCardTargetPageViewModel)DataContext; }
            }
    
    
            private void QuickCardTargetPage_Loaded(object sender, RoutedEventArgs e)
            {
                // Load the quick card parameters from the deep link URI.
                ViewModel.LoadUriParameters(this.NavigationContext.QueryString);
            }
    
    

    This creates a property for the ViewModel so that the LoadUriParameters method can be called. In the handler for the page Loaded event, the NavigationContext QueryString property is passed to the ViewModel so that the parameters can be extracted from the deep link URI.

In this section, you add text to the main page for a standard app launch.

To complete the app

  • In the main page of the app, MainPage.xaml, replace the grid named LayoutRoot with the following code.

        <!--LayoutRoot is the root grid where all page content is placed-->
        <Grid x:Name="LayoutRoot" Background="Transparent">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
    
            <!--TitlePanel contains the name of the app and page title-->
            <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
                <TextBlock 
                    x:Name="ApplicationTitle" 
                    Text="QUICK CARD EXAMPLE" 
                    Style="{StaticResource PhoneTextNormalStyle}"/>
                <TextBlock 
                    x:Name="PageTitle" 
                    Text="main page" 
                    Margin="9,-7,0,0" 
                    Style="{StaticResource PhoneTextTitle1Style}"/>
            </StackPanel>
    
            <!--ContentPanel - place additional content here-->
            <Grid x:Name="ContentPanel" Grid.Row="1" Margin="24,0,42,338">
                <TextBlock 
                    Text="With Search extensibility, you can navigate directly to a relevant page in your app from a quick card."
                    TextWrapping="Wrap"  
                    Style="{StaticResource PhoneTextAccentStyle}" 
                    Margin="0,0,12,181" />
    
                <TextBlock Text="To launch this app from a quick card, perform the testing steps outlined in the documentation."
                    TextWrapping="Wrap" 
                    Style="{StaticResource PhoneTextAccentStyle}" 
                    Margin="0,94,0,83" />
            </Grid>
        </Grid>
    
    

    This completes construction of the app.

This app is designed to help you explore live quick cards. In this section, you search for products, movies, and places that are associated with the extensions that were configured in the app manifest file. After locating a quick card, you launch your app to see the parameters that were passed to your app from the deep link URI.

Launching a Windows Phone OS 7.1 app from a quick card breaks the debugging connection. This limitation does not exist for Windows Phone 8 apps.

Important noteImportant Note:

Testing your app with quick cards requires an internet connect from your PC or Windows Phone device.

To test with a product card

  1. Press F5 to debug your app and deploy it to the emulator or device.

  2. After the app loads, tap the hardware Search button to open Bing.

  3. In Bing, enter a search term that is related to video game products, such as a video game console name. For example, “xbox 360” returns product cards related to Xbox 360 consoles. To test a product card with the Bing_Products_Video_Games extension, two things are required:

    • Bing must consider the search term relevant to video game products.

    • Product cards relevant to the search term must already exist at Bing and be associated with the Bing_Products_Video_Games extension.

  4. On the web or shopping pivot page, select a product under the products heading. This launches the quick card related to the product.

    TipTip:

    If you don’t see the products heading, try a different search term or add an additional product extension to the WMAppManifest.xml and Extras.xml files. For a complete list of search extensions, see Search registration and launch reference for Windows Phone 8.

  5. On the quick card for the product, swipe to the apps pivot page and tap on the app. Note that the caption reads Product URI Details.

    NoteNote:

    If you don’t see an apps pivot page, the particular product card isn’t associated with the product extension listed in the WMAppManifest.xml and Extras.xml files. Tap the Back button and try a different product card.

  6. After tapping the app in the apps pivot page, observe that the QuickCardTargetPage.xaml page displays the parameters in the deep link URI for the product.

To test with a movie card

  1. Press F5 to debug your app and deploy it to the emulator or device. This step is optional if you have already deployed the app.

  2. After the app loads, tap the hardware Search button to open Bing.

  3. In Bing, enter a search term that is related to movies that are currently in theaters, such as “movies”, “movies in theaters” or the name of a movie playing near you. To test a movie card with the Bing_Movies extension, two things are required:

    • Bing must consider the search term relevant to movies that are currently in theaters.

    • Movie cards relevant to the search term must already exist at Bing and be associated with the Bing_Movies extension.

  4. On the web pivot page, tap the movies listed in the search results below the Movies near… heading. This launches a list of quick cards for current movies. Tap one from the list.

    NoteNote:

    If you don’t see movies listed in the search results, try a different search term. There are no additional extensions available for movies.

  5. On the quick card for the movie, swipe to the apps pivot page, and then tap on the app. Note that the caption reads Movie URI Details.

  6. After tapping the app in the apps pivot page, observe that the QuickCardTargetPage.xaml page displays the parameters in the deep link URI for the movie.

To test with a place card

  1. Press F5 to debug your app and deploy it to the emulator or device.

  2. After the app loads, tap the hardware Search button to open Bing.

  3. In Bing, enter a search term that is related to food and dining, such as “food” or the name of a restaurant near you. To test a place card with the Bing_Places_Food_and_Dining extension, two things are required:

    • Bing must consider the search term relevant to a food and dining location.

    • Place cards relevant to the search term must already exist at Bing and be associated with the Bing_Places_Food_and_Dining extension.

  4. On the local pivot page, select a food and dining location under the map that’s displayed. This launches the quick card related to that place.

    TipTip:

    If you don’t see results on the local pivot page, try a different search term or add an additional place extension to the WMAppManifest.xml and Extras.xml files. For a complete list of search extensions, see Search registration and launch reference for Windows Phone 8.

  5. On the quick card for the place, swipe to the apps pivot page and tap on the app. Note that the caption reads Place URI Details.

    NoteNote:

    If you don’t see an apps pivot page, the particular place card isn’t associated with the place extension listed in the WMAppManifest.xml and Extras.xml files. Tap the Back button and try a different place card.

  6. After tapping the app in the apps pivot page, observe that the QuickCardTargetPage.xaml page displays the parameters in the deep link URI for the place.

The debugging process breaks when a Windows Phone OS 7.1 app is launched from a quick card. To debug a Search extensibility launch to your app, you need to simulate a deep link URI. To do this, perform the following procedure to temporarily replace the DefaultTask element in the WMAppManifest.xml file.

This debugging limitation doesn’t apply to Windows Phone 8 apps. When debugging a Windows Phone 8 app, you can set breakpoints in the URI mapper and use the debugging tools to examine the contents of the deep link URI. Although simulating a search extensibility launch isn’t necessary in Windows Phone 8, you may want to use it as a convenient way to launch your app with a specific URI.

To debug the app on Windows Phone 8

  1. Set a debugging break point somewhere in your app. To see the deep link URI that is sent from a quick card, set a debugging breakpoint in your URI mapper code.

  2. Follow the test steps described earlier in this topic to launch the app from the various quick cards.

To debug the app on Windows Phone OS 7.1

  1. In the app manifest file, WMAppManifest.xml, temporarily comment the original DefaultTask element.

    Important noteImportant Note:

    Commenting out the original DefaultTask element prevents your app from performing a standard launch to the main page; it is important to uncomment this element when you are finished debugging.

  2. In WMAppManifest.xml, add the following temporary DefaultTask element to the Tasks element.

    <DefaultTask Name="_default" NavigationPage="SearchExtras?MovieName=Test&amp;Category=Bing_Movies" />
    

    This DefaultTask element simulates a movie card for a movie named “Test”.

  3. Press F5 to debug your app and deploy it to the emulator or device.

  4. Observe that the app launches directly to the QuickCardTargetPage.xaml page and displays the parameters in the deep link URI for a movie named Test.

  5. In WMAppManifest.xml, comment out the temporary DefaultTask element and uncomment the original. When finished, the Tasks element should look like the following code.

    <Tasks>
      <DefaultTask  Name ="_default" NavigationPage="MainPage.xaml"/>
      <!--<DefaultTask  Name="_default" NavigationPage="SearchExtras?MovieName=Test&amp;Category=Bing_Movies" />-->
    </Tasks>
    

Mostra:
© 2014 Microsoft