Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8965533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:49:28+00:00 2026-06-15T16:49:28+00:00

I use the following code to take the snap using the PhotoCaptureDevice option in

  • 0

I use the following code to take the snap using the PhotoCaptureDevice option in Windows Phone 8.

if (PhotoCaptureDevice.AvailableSensorLocations.Contains(CameraSensorLocation.Back) ||
                PhotoCaptureDevice.AvailableSensorLocations.Contains(CameraSensorLocation.Front))
            {
                // Initialize the camera, when available.
                if (PhotoCaptureDevice.AvailableSensorLocations.Contains(CameraSensorLocation.Back))
                {
                    // Use the back camera.
                    System.Collections.Generic.IReadOnlyList<Windows.Foundation.Size> SupportedResolutions =
                        PhotoCaptureDevice.GetAvailableCaptureResolutions(CameraSensorLocation.Back);
                    Windows.Foundation.Size res = SupportedResolutions[0];
                    d = await PhotoCaptureDevice.OpenAsync(CameraSensorLocation.Back, res);
                }
                else
                {
                    // Otherwise, use the front camera.
                    System.Collections.Generic.IReadOnlyList<Windows.Foundation.Size> SupportedResolutions =
                        PhotoCaptureDevice.GetAvailableCaptureResolutions(CameraSensorLocation.Front);
                    Windows.Foundation.Size res = SupportedResolutions[0];
                    d = await PhotoCaptureDevice.OpenAsync(CameraSensorLocation.Front, res);
                }

                await d.SetPreviewResolutionAsync(new Windows.Foundation.Size(640, 480));
                await d.SetCaptureResolutionAsync(new Windows.Foundation.Size(640, 480));

                d.SetProperty(KnownCameraGeneralProperties.EncodeWithOrientation,
                              d.SensorLocation == CameraSensorLocation.Back ?
                              d.SensorRotationInDegrees : -d.SensorRotationInDegrees);

                _device = d;
            }

Finally i set this device to the Source of the Video brush. But i come from the dormant state when the application goes to this state by press and hold of back key, it shows the empty page and does not display any camera. Could you please anyone help me on this ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:49:30+00:00Added an answer on June 15, 2026 at 4:49 pm

    Nokia has a great sample app of the many capabilities enabled in WP8’s PhotoCaptureDevice. Check it out @ http://projects.developer.nokia.com/cameraexplorer

    There’s even an end-to-end example of using PhotoCaptureDevice as the VideoBrush.SetSource() right on the first page. Start from OnNavigatedTo method on MainPage.xaml.cs to see how to initialize a Camera Viewfinder with PhotoCaptureDevice @ http://projects.developer.nokia.com/cameraexplorer/browser/CameraExplorer/MainPage.xaml.cs

    Here are the relevant parts:

        /// <summary>
        /// If camera has not been initialized when navigating to this page, initialization
        /// will be started asynchronously in this method. Once initialization has been
        /// completed the camera will be set as a source to the VideoBrush element
        /// declared in XAML. On-screen controls are enabled when camera has been initialized.
        /// </summary>
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            if (_dataContext.Device == null)
            {
                ShowProgress("Initializing camera...");
    
                await InitializeCamera(CameraSensorLocation.Back);
    
                HideProgress();
            }
    
            videoBrush.RelativeTransform = new CompositeTransform()
            {
                CenterX = 0.5,
                CenterY = 0.5,
                Rotation = _dataContext.Device.SensorLocation == CameraSensorLocation.Back ?
                           _dataContext.Device.SensorRotationInDegrees :
                         - _dataContext.Device.SensorRotationInDegrees
            };
    
            videoBrush.SetSource(_dataContext.Device);
    
            overlayComboBox.Opacity = 1;
    
            SetScreenButtonsEnabled(true);
            SetCameraButtonsEnabled(true);
    
            base.OnNavigatedTo(e);
        }
    
        /// <summary>
        /// Initializes camera. Once initialized the instance is set to the DataContext.Device property
        /// for further usage from this or other pages.
        /// </summary>
        /// <param name="sensorLocation">Camera sensor to initialize</param>
        private async Task InitializeCamera(CameraSensorLocation sensorLocation)
        {
            Windows.Foundation.Size initialResolution = new Windows.Foundation.Size(640, 480);
            Windows.Foundation.Size previewResolution = new Windows.Foundation.Size(640, 480);
            Windows.Foundation.Size captureResolution = new Windows.Foundation.Size(640, 480);
    
            PhotoCaptureDevice d = await PhotoCaptureDevice.OpenAsync(sensorLocation, initialResolution);
    
            await d.SetPreviewResolutionAsync(previewResolution);
            await d.SetCaptureResolutionAsync(captureResolution);
    
            d.SetProperty(KnownCameraGeneralProperties.EncodeWithOrientation,
                          d.SensorLocation == CameraSensorLocation.Back ?
                          d.SensorRotationInDegrees : - d.SensorRotationInDegrees);
    
            _dataContext.Device = d;
        }
    

    And relevant XAML:

            <Canvas x:Name="VideoCanvas">
                <Canvas.Background>
                    <VideoBrush x:Name="videoBrush"/>
                </Canvas.Background>
                <Rectangle x:Name="FocusIndicator" Stroke='Red' Opacity="0.7" Width="80" Height="80" StrokeThickness="5" Visibility="Collapsed"/>
            </Canvas>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use following code take a Picture from camera and to obtain picture's path.
I am trying to use the following code to take screen shots from my
If I use the following code, getline doesn't take the last input(for last iteration
I use following code: Create a retry policy, when error, retry after 1 second,
I just use following code to add an image to my project, var paper
I use VS2010, C# to develop Silverlight 4 app, I use following code in
I have an array of objects, and i use following code to get in
I use the following code to crop an image according to a rectangular selection
I use the following code to copy a particular directory and its contents to
I use the following code to fill all empty keys in sub-arrays with ``

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.