Prerequisites
- Visual Studio 2015
Now let's get started with the following steps:
Step 1 : Create Windows Universal Project
Open Visual Studio 2015 and Click File -> New -> Project Option for New Universal App.

Step 2: Giving the Project Name
Then, New Project Window will open, there you can select an Installed -> Template -> Visual C# -> Windows -> Universal and select a Blank App (Universal Windows).
Type Project Name ImageApp and click the OK button

Step 3: Setting the platform Versions
Here, we choose the Target Version and Minimum Version for our Universal Windows application and click OK button

Step 4: Choose Designer Window
Now we go to the Solution Explorer and select MainPage.xaml

Step 5: Designing the App
Click on the XAML file and Add the following coding

The Window looks like this,

- <Page.BottomAppBar>
- <AppBar IsOpen="True" IsSticky="True">
- <StackPanel Orientation="Horizontal">
- <AppBarButton Icon="RepeatAll" Label="Rotate" Click="Pitch_Click" />
- <AppBarButton Icon="Rotate" Label="Flip" Click="Flip_Click" /> </StackPanel>
- </AppBar>
- </Page.BottomAppBar>
- <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
- <Grid>
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto" />
- <RowDefinition Height="*" /> </Grid.RowDefinitions>
- <Image Grid.Row="1" Margin="60" Stretch="Uniform" Name="Display" Source="Assets/UWP.png">
- <Image.Projection>
- <PlaneProjection/> </Image.Projection>
- </Image>
- </Grid>
- </Grid>
- </Page>
Now we want to rotate and flip the Image. Add the following code in the MainPage.xaml.cs. Add the following code.


- using Windows.UI.Xaml.Media;
- using Windows.UI.Xaml.Media.Animation;
- private Storyboard rotation = new Storyboard();
- private bool rotating = false;
- public void Rotate(string axis, ref Image target) {
- if (rotating) {
- rotation.Stop();
- rotating = false;
- } else {
- DoubleAnimation animation = new DoubleAnimation();
- animation.From = 0.0;
- animation.To = 360.0;
- animation.BeginTime = TimeSpan.FromSeconds(1);
- animation.RepeatBehavior = RepeatBehavior.Forever;
- Storyboard.SetTarget(animation, Display);
- Storyboard.SetTargetProperty(animation, "(UIElement.Projection).(PlaneProjection.Rotation" + "Y" + ")");
- rotation.Children.Clear();
- rotation.Children.Add(animation);
- rotation.Begin();
- rotating = true;
- }
- }
- private void Pitch_Click(object sender, RoutedEventArgs e) {
- Rotate("X", ref Display);
- }
- private void Flip_Click(object sender, RoutedEventArgs e) {
- ScaleTransform transform = new ScaleTransform();
- transform.ScaleY = -1;
- Display.RenderTransform = transform;
- }
Now we are ready to run our Project, So Click the Local Machine for running the Application.

Output
- Click on the Rotate Button,

- It Rotates,

- Next, Stop the Rotation by again clicking on the rotate button,

- Now Click on the Flip Button,

- Next Click on the Rotate button, it rotates in the Flip position.

Conclusion: I hope you understood how to rotate and Flip the Image in Universal Windows and how to run it.

ManiKanth VangalaPosted Aug 30, 2021, 4:08 AM
Can i downoad this project for reference ?