In this article we are going to see how to create an analog clock in Windows 10 universal app using XAML and C#.
Create new Windows 10 universal application. For creating a new Windows 10 universal project, refer to the following:
I am going to use an ellipse and rectangle control to draw the clock.
Go to MainPage.Xaml page and write the following xaml code,
- <Grid Background="{StaticResourceApplicationPageBackgroundThemeBrush}">
- <Grid Width="300" Height="300">
- <Ellipse Width="300" Height="300" Fill="DarkOliveGreen"></Ellipse>
- <!--for Second -->
- <Rectangle Margin="150,0,149,150" Name="second" Stroke="White" Height="120" VerticalAlignment="Bottom">
- <Rectangle.RenderTransform>
- <RotateTransform x:Name="secondHand" CenterX="0" CenterY="120" Angle="0" /> </Rectangle.RenderTransform>
- </Rectangle>
- <!-- for Minute -->
- <Rectangle Margin="150,49,149,151" Name="minute" Stroke="LightGreen">
- <Rectangle.RenderTransform>
- <RotateTransform x:Name="minuteHand" CenterX="0" CenterY="100" Angle="0" /> </Rectangle.RenderTransform>
- </Rectangle>
- <!-- for Hour -->
- <Rectangle Margin="150,80,149,150" Name="hour " Stroke="LightYellow">
- <Rectangle.RenderTransform>
- <RotateTransform x:Name="hourHand" CenterX="0" CenterY="70" Angle="0" /> </Rectangle.RenderTransform>
- </Rectangle>
- </Grid>
- </Grid>


David JohnsonPosted Apr 6, 2016, 7:17 AM
had to do a few fixups do to the errors in formatting but great
David JohnsonPosted Apr 6, 2016, 7:16 AM
Great article submitted to hockeyapp https://rink.hockeyapp.net/manage/apps/308616/app_versions/1and available on onedrive https://onedrive.live.com/redir?resid=C1BF36AA573085B6!89888&authkey=!AEPLVnEy-NrDV2U&ithint=file%2czip
Suresh MPosted Apr 6, 2016, 6:55 AM
Thank you
S.Ravi KumarPosted Apr 6, 2016, 1:54 AM
Nice
Debasis SahaPosted Apr 5, 2016, 10:22 AM
Nice One..
Rahul Kumar SaxenaPosted Apr 5, 2016, 8:53 AM
Good One
Vignesh ManiPosted Apr 5, 2016, 8:19 AM
Nice one