Silverlight SDK for Microsoft Bing
App Class
OverviewMicrosoft.Bing.ApplicationApp
Implements a Silverlight Application for demonstrating the capabilities of the Microsoft Bing search API and the Microsoft Silverlight SDK for Bing.
Declaration Syntax
C#Visual BasicVisual C++
public class App : Application
Public Class App _
	Inherits Application
public ref class App : public Application
Members
All MembersConstructorsMethodsPropertiesEvents



IconMemberDescription
App()()()
Instantiates a new App instance.

Equals(Object)
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Exit (Inherited from Application.)
GetHashCode()()()
Serves as a hash function for a particular type.
(Inherited from Object.)
GetType()()()
Gets the Type of the current instance.
(Inherited from Object.)
Host()()() (Inherited from Application.)
InitializeComponent()()()
InitializeComponent

Resources (Inherited from Application.)
RootVisual()()() (Inherited from Application.)
Startup (Inherited from Application.)
ToString()()()
Returns a String that represents the current Object.
(Inherited from Object.)
UnhandledException()()() (Inherited from Application.)
Examples

The Microsoft Bing SDK is very easy to use in terms of Xaml implementation and binding to the Search data itself. The SearchEnvironment singleton is where the bulk of the logic and data operations take place. This object is also a DependencyObject and implements INotifyPropertyChanged, which provides support for data binding.

To execute a search, you only need to create a SearchRequest, populate its Query property, and then insure that you have set the SearchMedia property on the SearchEnvironment. Then, call the method BeginSearch(String), insuring that you have provided a handler for SearchCompleted.

You should also bind any display controls - typically ItemsControl instances, such as ListBox etc - to the Results property. This property is of type SearchResults and is an observable collection. This means that you can data bind your ItemsControl instances in advance, like this:

CopyC#
//Assumes a ItemsControl named "MyList" exists...
MyList.ItemsSource = SearchEnvironment.Default.Results;

//Consume SearchEnvironment Events
SearchEnvironment.Default.SearchStarted += new EventHandler(OnSearchStarted);
SearchEnvironment.Default.SearchCompleted += new EventHandler<SearchResponseEventArgs>(OnSearchCompleted);
SearchEnvironment.Default.Error += new EventHandler<ErrorEventArgs>(OnSearchError);

//Begin the Search (Assume a TextBox named "QueryText" exists)
SearchEnvironment.Default.PageSize = 20;
SearchEnvironment.Default.MediaType = SearchMedia.Web;
SearchEnvironment.Default.BeginSearch(QueryText.Text);

This should be done prior to executing any searches. Then when a search completes, the Results collection will become populated, if there are avialable results, and your ItemsControl control will automatically data bind and use the asynchronous layout framework in the Silverlight runtime.

Inheritance Hierarchy
See Also

Assembly: Microsoft.Bing.Application (Module: Microsoft.Bing.Application) Version: 1.0.0.0 (1.0.0.0)