This is digital Clock in WPF without installing digital font.

MainWindow.xaml

  1. <Window x:Class="Digital_Clock.MainWindow"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. Title="Current Time" Height="120" Width="290" ResizeMode="NoResize" WindowStyle="ToolWindow"Icon="1370614099_42192.ico">
  5. <Grid>
  6. <TextBlock Style="{StaticResource FontAwesome}" FontSize="80" Name="tbk_clock">
  7. <TextBlock.Foreground>
  8. <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
  9. <GradientStop Color="Black" Offset="0.52"/>
  10. <GradientStop Color="White"/>
  11. </LinearGradientBrush>
  12. </TextBlock.Foreground>
  13. <TextBlock.Background>
  14. <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
  15. <GradientStop Color="Black" Offset="0"/>
  16. <GradientStop Color="White" Offset="1"/>
  17. </LinearGradientBrush>
  18. </TextBlock.Background>
  19. </TextBlock>
  20. </Grid>
  21. </Window>
MainWindow.xaml.cs
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using System.Windows.Data;
  8. using System.Windows.Documents;
  9. using System.Windows.Input;
  10. using System.Windows.Media;
  11. using System.Windows.Media.Imaging;
  12. using System.Windows.Navigation;
  13. using System.Windows.Shapes;
  14. namespace Digital_Clock
  15. {
  16. /// <summary>
  17. /// Interaction logic for MainWindow.xaml
  18. /// </summary>
  19. public partial class MainWindow : Window
  20. {
  21. public MainWindow()
  22. {
  23. InitializeComponent();
  24. System.Windows.Threading.DispatcherTimer myDispatcherTimer = newSystem.Windows.Threading.DispatcherTimer();
  25. myDispatcherTimer.Interval = new TimeSpan(0, 0, 0, 0, 100); // 100 Milliseconds
  26. myDispatcherTimer.Tick += myDispatcherTimer_Tick;
  27. myDispatcherTimer.Start();
  28. }
  29. void myDispatcherTimer_Tick(object sender, EventArgs e)
  30. {
  31. tbk_clock.Text = DateTime.Now.ToString("hh:mm:ss");
  32. }
  33. }
  34. }
App.xaml
  1. <Application x:Class="Digital_Clock.App"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. StartupUri="MainWindow.xaml">
  5. <Application.Resources>
  6. <Style x:Key="FontAwesome" TargetType="TextBlock">
  7. <Setter Property="TextElement.FontFamily"Value="/Digital_Clock;Component/Fonts/#DS-Digital"/>
  8. </Style>
  9. </Application.Resources>
  10. </Application>
Output:

clock