I have gone through several Q&A here and on different portals but cannot get this working…
My page orientation is Portrait…
<Rectangle x:Name="videoRectangle" Margin="0,0,0,0">
<Rectangle.Fill>
<VideoBrush x:Name="viewfinderBrush" AlignmentX="Left" AlignmentY="Top" Stretch="UniformToFill">
<VideoBrush.RelativeTransform>
<CompositeTransform x:Name="videoBrushTransform" CenterX="0.5" CenterY="0.5" />
</VideoBrush.RelativeTransform>
</VideoBrush>
</Rectangle.Fill>
</Rectangle>
the code behind ARPage_OrientationChanged never gets invoked
public ARPage()
{
InitializeComponent();
this.OrientationChanged += ARPage_OrientationChanged;
}
void ARPage_OrientationChanged(object sender, OrientationChangedEventArgs e)
{
abc.Text = e.Orientation.ToString();
switch (e.Orientation)
{
case PageOrientation.Landscape:
case PageOrientation.LandscapeLeft:
videoBrushTransform.Rotation = 0;
break;
case PageOrientation.LandscapeRight:
videoBrushTransform.Rotation = -45;
break;
case PageOrientation.Portrait:
case PageOrientation.PortraitUp:
videoBrushTransform.Rotation = -270;
break;
case PageOrientation.PortraitDown:
videoBrushTransform.Rotation = -90;
break;
}
}
The video brush always show video in landscape mode…
what i am doing wrong
it is not necessary to assign the event in the constructor, you can do this: