c# - The following code doesnt work -


i copied following code here: https://code.msdn.microsoft.com/windowsapps/windowsphone-store-81-vs-25c80c2a#content

mediacapture capturemanager;     async private void initcamera_click(object sender, routedeventargs e)     {         capturemanager = new mediacapture();         await capturemanager.initializeasync();     }      async private void startcapturepreview_click(object sender, routedeventargs e)     {         capturepreview.source = capturemanager;         await capturemanager.startpreviewasync();     }      async private void stopcapturepreview_click(object sender, routedeventargs e)     {         await capturemanager.stoppreviewasync();     }      async private void capturephoto_click(object sender, routedeventargs e)     {         imageencodingproperties imgformat = imageencodingproperties.createjpeg();          // create storage file in local app storage          storagefile file = await applicationdata.current.localfolder.createfileasync(             "testphoto.jpg",             creationcollisionoption.generateuniquename);          // take photo          await capturemanager.capturephototostoragefileasync(imgformat, file);          // photo bitmapimage          bitmapimage bmpimage = new bitmapimage(new uri(file.path));          // imagepreivew <image> object defined in xaml          imagepreview.source = bmpimage;     } 

when try running capturepreview not defined. removed line , 2 exceptions:

exception thrown: 'system.argumentexception' in mscorlib.ni.dll

exception thrown: 'system.argumentexception' in mscorlib.ni.dll

do know problem? windows phone 8.1 rt app

edit: same code can found here: https://msdn.microsoft.com/en-us/library/windows.media.capture.mediacapture.aspx?f=255&mspperror=-2147217396

"capturepreview" capture element. must add in following control in page.

<captureelement x:name="capturepreview" width="320" height="240" /> 

Comments