XAML Code
<Grid Margin="10">
<StackPanel VerticalAlignment="Center">
<Label Content="BC123456789"
FontSize="26"
FontWeight="Bold"
HorizontalAlignment="Center"
Margin="0,0,0,20"/>
<Label Content="Input Fahrenheit:"
FontSize="16"
FontWeight="Bold"
Margin="0,0,0,5"/>
<TextBox Name="FahrenheitInput"
FontSize="16"
Height="30"
Margin="0,0,0,15"/>
<Button Content="To Celsius"
Name="ConvertButton"
Background="Green"
Foreground="White"
FontSize="16"
FontWeight="Bold"
Height="40"
Click="ConvertButton_Click"
Margin="0,0,0,15"/>
<Label Name="ResultLabel"
FontSize="16"
FontWeight="Bold"
Content="Result:"
Margin="0,10,0,0"/>
</StackPanel>
</Grid>
</Window>
C# Code
using System;
using System.Windows;
using System.Windows.Controls;
namespace BC123456789
public partial class MainWindow : Window
public MainWindow()
InitializeComponent();
private void ConvertButton_Click(object sender, RoutedEventArgs e)
try
double fahrenheit = double.Parse(FahrenheitInput.Text);
double celsius = (fahrenheit - 32) * 5 / 9;
ResultLabel.Content = $"Result: {celsius:F2} °C";
catch (FormatException)
{
MessageBox.Show("Please enter a valid number.", "Input Error",
MessageBoxButton.OK, MessageBoxImage.Error);