Barcode for WPF > Getting Started > Quick Start: BarCode for WPF > Step 1: Setting Up the Application |
In this step, you begin by creating a new WPF application in Visual Studio and adding appropriate XAML markup to the MainWindow. Next, you add various controls including the C1Barcode control and other general controls like a combo box and three text blocks to set up the application.
XAML |
Copy Code
|
---|---|
<Window x:Class="BarCodeApp.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:c1="http://schemas.componentone.com/winfx/2006/xaml" xmlns:BarCode="clr-namespace:C1.BarCode;assembly=C1.WPF.BarCode.4" Title="BarCode Sample" Height="621.567" Width="1069.493"> |
XAML |
Copy Code
|
---|---|
<Grid.Resources> <Style TargetType="TextBlock"> <Setter Property="FontSize" Value="18"></Setter> </Style> <Style TargetType="TextBox"> <Setter Property="FontSize" Value="18"></Setter> </Style> <Style TargetType="ComboBox"> <Setter Property="FontSize" Value="18"></Setter> </Style> </Grid.Resources> <Border HorizontalAlignment="Center"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="20*"/> <RowDefinition Height="20*" /> <RowDefinition Height="60*" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="40*" /> <ColumnDefinition Width="60*" /> </Grid.ColumnDefinitions> |
XAML |
Copy Code
|
---|---|
<TextBlock Text="CodeType:" VerticalAlignment="Center"></TextBlock> <ComboBox x:Name="cbCodeType" HorizontalAlignment="Left" Grid.Column="1" Width="414" Height="50" SelectionChanged="cbCodeType_SelectionChanged" /> <TextBlock Text="Text:" Grid.Row="1" VerticalAlignment="Center"></TextBlock> <TextBox x:Name="text" Text="{Binding Text, ElementName=barcode, UpdateSourceTrigger=PropertyChanged, FallbackValue='', Mode=TwoWay}" HorizontalAlignment="Left" Grid.Column="1" Grid.Row="1" Height="50" Width="414" TextChanged="text_TextChanged"/> <TextBlock Text="BarCode:" Grid.Row="2" VerticalAlignment="Center"/> <Grid Grid.Row="2" Grid.Column="1" Background="White" HorizontalAlignment="Left" Width="414"> </Grid> </Grid> </Border> |
XAMl |
Copy Code
|
---|---|
<Image Source="Resources/c1logo.png" x:Name="image" Width="70" Height="70" Margin="378,310,312,124" /> |
Ensure that your markup ends with </Grid> and </Window> tags.
With this, you have set up the application for this Quick Start guide.