OcrControl.OcrControl() Constructor

 

Deprecated. The OcrControl Constructor function creates an instance of the OcrControl Class.

Published date: March 4, 2014

Warning

The Bing OCR Control is deprecated as of March 12, 2014

Syntax

public OcrControl()
<Ocr:OcrControl .../>

Remarks

The easiest way to create an instance of The Bing Optical Character Recognition (OCR) Control is to drag it onto a XAML page from the Toolbox in Visual Studio. You can create an OcrControl instance in code if you have an existing XAML container for it to appear inside of.

Example

The following example creates an instance of the OCR Control on a XAML page.

<Grid ...>
    <Ocr:OcrControl x:Name="OCR" .../>
</Grid>

Example

The following example creates an OcrControl instance in code and places it inside a named container.

<Grid x:Name="OcrHost" .../>
<Button x:Name="btnStartOcr" Content="Start OCR" Click="btnStartOcr_Click" .../>
using Bing.Ocr;

OcrControl OCR;
private void btnStartOcr_Click(object sender, RoutedEventArgs e)
{
    // Create the control.
    OCR = new OcrControl();

    // Set credentials.
    OCR.ClientId = 
            <your client ID>;
    OCR.ClientSecret = 
            <your client secret>;

    // Assign event handlers.
    OCR.Completed += Ocr_Completed;
    OCR.Failed += Ocr_Failed;
    OCR.Loaded += Ocr_Load;

    // Place the control on the page.
    OcrHost.Children.Add(OCR);
}

private async void Ocr_Load(object sender, RoutedEventArgs e)
{
    await OCR.StartPreviewAsync();
}

The Completed and Failed event handlers are not shown. For the complete example and detailed instructions, see Embedding the Bing OCR Control in an Application.

Requirements

Minimum Supported Client

Windows 8.1

Required Extensions

Bing OCR

Namespace

Bing.Ocr