title: How to rotate camera view in CaptureElement?
body: <p>I have a following problem. I wrote <code>StackPanel</code> with <code>CaptureElement</code>:</p>
  <pre><code> &lt;StackPanel&gt;
          &lt;CaptureElement x:Name=&quot;PreviewElement&quot;
                          HorizontalAlignment=&quot;Center&quot; 
                          VerticalAlignment=&quot;Center&quot;
                          Width=&quot;380&quot;
                          Height=&quot;560&quot;
                          Stretch=&quot;UniformToFill&quot;/&gt;
   &lt;/StackPanel&gt;
  </code></pre>
  <p>In xaml.cs file under that view:</p>
  <pre><code>protected override async void OnNavigatedTo(NavigationEventArgs e)
  {
       cameraCapture = new CameraCapture();
       PreviewElement.Source = await cameraCapture.Initialize();
       await cameraCapture.StartPreview();            
  } 
  </code></pre>
  <p>And I have a class CameraCapture.cs in which I have all methods:</p>
  <pre><code>public class CameraCapture 
      {
          MediaCapture mediaCapture;
          ImageEncodingProperties imgEncodingProperties;
  
          public async Task&lt;MediaCapture&gt; Initialize(CaptureUse primaryUse = CaptureUse.Photo)
          {
              //Create media capture and INIT
              var cameraID = await GetCameraID(Windows.Devices.Enumeration.Panel.Back);
              mediaCapture = new MediaCapture();
              await mediaCapture.InitializeAsync(new MediaCaptureInitializationSettings
              {
                  StreamingCaptureMode = StreamingCaptureMode.Video,
                  PhotoCaptureSource = PhotoCaptureSource.Photo,
                  AudioDeviceId = string.Empty,
                  VideoDeviceId = cameraID.Id
              });
              mediaCapture.VideoDeviceController.PrimaryUse = primaryUse;
  
              //Create photo encoding properties as JPEG and set the size that should be use for photo capturing
              imgEncodingProperties = ImageEncodingProperties.CreateJpeg();
              imgEncodingProperties.Width = 640;
              imgEncodingProperties.Height = 480;
  
              return mediaCapture;
          }
          public async Task StartPreview()
          {
              //Start preview stream
              await mediaCapture.StartPreviewAsync();
          }       
          private static async Task&lt;DeviceInformation&gt; GetCameraID(Windows.Devices.Enumeration.Panel desired)
          {
              DeviceInformation deviceID = (await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture))
                  .FirstOrDefault(x =&gt; x.EnclosureLocation != null &amp;&amp; x.EnclosureLocation.Panel == desired);
  
              if (deviceID != null) return deviceID;
              else throw new Exception(string.Format(&quot;Camera of type {0} doesn't exist.&quot;, desired));
          }
      }
  </code></pre>
  <p>When I run application in portrait rotation I have camera view rotated by 90 degrees counterclockwise. After I turn to Landscape view I have smaller window in which is camera view but rotation is good.</p>
  <p>Any ideas how to solve this problem?</p>