C#.net

Currency Converter App WPF in C#.NET

This tutorial will teach how to make a Currency Converter in WPF C#.net.

MainWindow.xaml

<Window x:Class="WPFCurrencyConverter.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WPFCurrencyConverter"
        mc:Ignorable="d"
        Title="Currency Converter App" Height="250" Width="400">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="25"/>
            <ColumnDefinition Width="350"/>
            <ColumnDefinition Width="25"/>
        </Grid.ColumnDefinitions>

        <Grid.RowDefinitions>
            <RowDefinition Height="25"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="5"/>
        </Grid.RowDefinitions>

        <StackPanel Grid.Column="1"
                    Grid.Row="1" Grid.ColumnSpan="2">

            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="100"/>
                    <ColumnDefinition Width="250"/>

                </Grid.ColumnDefinitions>

                <Grid.RowDefinitions>
                    <RowDefinition Height="25"/>
                    <RowDefinition Height="5"/>
                    <RowDefinition Height="25"/>
                    <RowDefinition Height="5"/>
                    <RowDefinition Height="25"/>
                    <RowDefinition Height="5"/>
                    <RowDefinition Height="25"/>
                    <RowDefinition Height="10"/>

                </Grid.RowDefinitions>

                <Label Content="Amount :"
                       Grid.Row="0"
                       Grid.Column="0"
                      
                       />

                <TextBox
                    x:Name="TextBoxAmount"
                    Grid.Row="0"
                    Grid.Column="1"
                    />

                <Label Content="From :" 
                       Grid.Row="2"
                       Grid.Column="0"
                       
                       />

                <ComboBox  Name="CboFrom" HorizontalAlignment="Left" VerticalAlignment="Top" Width="100" Height="25"  Grid.Row="2"
                    Grid.Column="1">
                    <ComboBoxItem Content="USD"></ComboBoxItem>

                </ComboBox>

                <Label Content="To :"
                         Grid.Row="4"
                         Grid.Column="0"
                       />



                <ComboBox  Name="CboTo" HorizontalAlignment="Left" VerticalAlignment="Top"   
                           Width="100" Height="25"   Grid.Row="4" 
                           Grid.Column="1">
                    <ComboBoxItem Content="Srilankan Rupees"></ComboBoxItem>
                    <ComboBoxItem Content="Indian Rupees"></ComboBoxItem>  

                </ComboBox>


                <Label Content="Total :"
                         Grid.Row="6"
                         Grid.Column="0"
                       />

                <TextBox
                    x:Name="TextBoxTotal"
                    Grid.Row="6"
                    Grid.Column="1"
                    />

            </Grid>

            <StackPanel
                     Grid.Row="8"
                     Grid.ColumnSpan="2"
                     Orientation="Horizontal">

                <Button
                        Width="60"
                        Height="30"
                        Content="Convert"
                    
                        x:Name="ButtonConvert"
                        Margin="10 0 10 0"
                        Click="ButtonConvert_Click" Background="#FF04097E" Foreground="White"/>
            </StackPanel>

        </StackPanel>

    </Grid>
</Window>

MainWindow.xaml.cs

 public MainWindow()
        {
            InitializeComponent();
            ButtonConvert.Click += ButtonConvert_Click;
        }

        private void ButtonConvert_Click(object sender, RoutedEventArgs e)
        {

            double tot;
            double amount = double.Parse(TextBoxAmount.Text);



            if (((ComboBoxItem)CboFrom.SelectedItem).Content.ToString() == "USD" &&
                ((ComboBoxItem)CboTo.SelectedItem).Content.ToString() == "Srilankan Rupees")
            {
                tot = amount * 179.50;
                TextBoxTotal.Text = tot.ToString();

            }
            else if (((ComboBoxItem)CboFrom.SelectedItem).Content.ToString() == "USD" &&
                ((ComboBoxItem)CboTo.SelectedItem).Content.ToString() == "Indian Rupees")
            {
                tot = amount * 70;
                TextBoxTotal.Text = tot.ToString();
            }

        }

i have attached the video link below. which will do this tutorials step by step.

 

admin

Recent Posts

Build Simple Water System Calculator in Java Using Swing

If you're just beginning to learn Java GUI programming creating an Water System Calculator is a fantastic project for…

5 days ago

GitHub Copilot vs Microsoft Copilot Best AI Tool to Use in 2025

GitHub is a powerful tool used by teams and developers around the globe. This guide is…

1 week ago

Chat with Claude AI Free – Your Super-Smart AI Buddy

It's like having a super-smart buddy that is always there to help you write stories,…

2 weeks ago

Best Festivals UK 2025 [Free Guide Included]

The UK is known for its rich history, diverse culture, and most of all  its…

2 weeks ago

Bank Holidays 2025 UK – Plan Your Perfect Long Weekends

Do you have a plan for your next holiday? Being aware of the Bank Holidays within the…

2 weeks ago

Master Cursor AI Full Guide for Students & Creators

The world is rapidly changing of software development AI-assisted tools for coding have become the main focus. As…

2 weeks ago