Visual Studio 2019 (WPF VB.Net Source Code & XAML) How to Create a Simple Hello World Program in VB.Net Windows Presentation Foundation (WPF App)


Visual Studio 2019 (WPF VB.Net Source Code & XAML) How to Create a Simple Hello, World! Program in VB.Net Windows Presentation Foundation (WPF Application).

🎓 Master Visual Basic .NET and Access Database By Building the Point Of Sale System (POS).
ðŸ“ē Enroll Now: https://bit.ly/2WcbRhX

[VB.NET Screenshot: 1]


[VB.NET Screenshot: 2]


[VB.NET YouTube Video Tutorial]


[XAML & VB.NET Code Behind]
Short link: http://bit.ly/2GjxsOC

MainWindow.xaml

<Window x:Class="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"
        mc:Ignorable="d"
        Title="WPF (VB.NET) Simple Hello, World! Program : Code A Minute : iBasskung Tutorial"
        Height="450" Width="800"
        Background="DarkCyan"
        WindowStartupLocation="CenterScreen"
        WindowState="Normal"
        WindowStyle="ThreeDBorderWindow">
 
    <Grid Margin="15">
     
        <StackPanel Orientation="Vertical"
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Center">
         
            <TextBlock Name="resultTextBlock"
                       FontSize="100"
                       Text="My TextBlock"
                       Foreground="White"
                       TextWrapping="Wrap"
                       HorizontalAlignment="Center"
                       VerticalAlignment="Top"
                       Margin="0,0,0,30"/>

            <Button Name="sayHelloButton"
                    Content="Let's say Hello :)"
                    Width="740"
                    HorizontalAlignment="Stretch"
                    HorizontalContentAlignment="Center"
                    VerticalAlignment="Stretch"
                    VerticalContentAlignment="Center"
                    FontSize="72"
                    Background="Crimson"
                    Foreground="White"
                    Height="140"
                    BorderBrush="Gold"
                    BorderThickness="6"/>

        </StackPanel>
     
    </Grid>
 
</Window>

=================

MainWindow.xaml.vb

Option Explicit On
Option Strict On

Class MainWindow

    Public Sub New()
        ' This call is required by the designer.
        InitializeComponent()
        ' Add any initialization after the InitializeComponent() call.
        resultTextBlock.Text = "..."
    End Sub

    Private Sub SayHelloButton_Click(sender As Object, e As RoutedEventArgs) Handles sayHelloButton.Click

        If Not resultTextBlock.Text.Equals("Hello, World!") Then
            resultTextBlock.Text = "Hello, World!"
        Else
            resultTextBlock.Text = "Hello, WPF !!!"
        End If

        ' Ex.1
        MessageBox.Show("Hello, World! WPF Application.", "Simple WPF (VB.NET) Hello, World! Program", MessageBoxButton.OK, MessageBoxImage.Information)

        ' Ex.2
        Dim caption As String = "Hello, World! WPF Application."
        Dim btnOK As MessageBoxButton = MessageBoxButton.OK
        Dim imgExc As MessageBoxImage = MessageBoxImage.Exclamation

        Dim message As String = $"Hello, World!{Environment.NewLine}Hello, WPF Application!"

        MessageBox.Show(message, caption, btnOK, imgExc)

    End Sub

End Class

Comments

Post a Comment