| Home | Course Index | << Prev. | Next >> | PDF Version of this Page |
![]() |
Course API Comparison
|
For an introduction into Microsofts XAML see: |
XAML |
For an introduction into Microsofts WPF-API see: | WPF |
|
Comparison of Microsofts Windows Forms API with WPF: | Compare Windows Forms and WPF |
Guidance for Visual C# 2010 Express Edition:
1) Main Menu after start of VS 2010: Tools → Options → check lower left checkbox: Show all Settings → Projects and Solutions → Visual Studio projects location: → C:\temp.
2) Main Menu after start of VS 2010: File → New Project... → Visual Studio installed templates: Empty Project
Name: compareWPF_Xaml → OK.
3) Main Menu after start of VS 2010: Project... → compareWPF_Xaml Properties → Application → Output type: switch from Console Application to Windows Application.
|
4) In the Solution Explorer-window right click the branch References. Add Reference → .NET-tab → scroll down until you find Presentation Core. Click OK. Check whether Presentation Core arrived in the branch References. In the same way you have to add 3 more references: Presentation Framework, System and WindowsBase. 5) In the Solution Explorer-window right click the main branch compareWPF_Xaml. Choose Add → 6) In the Solution Explorer-window right click the main branch compareWPF_Xaml. Choose Add → |
![]() |
Write the following lines into the empty window of compareWPF_Xaml.xaml:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="myNameSpace.WPF_Xaml"
Title="WPF Windows Program in XAML + C#"
Width="500" Height="80" x:Name="window">
<Viewbox>
<Border BorderBrush="Black" BorderThickness="2">
<StackPanel Orientation="Horizontal" Margin="2">
<Button Content="Talk!" Click="button1Click" HorizontalAlignment="Left"/>
<TextBox x:Name="textBox" Margin="2,0,2,0" MinWidth="300" TextAlignment="Center"/>
<Button Content="Clear" Click="button2Click" HorizontalAlignment="Right"/>
</StackPanel>
</Border>
</Viewbox>
</Window>
Write the following lines into the empty window of compareWPF_Xaml.cs:
using System;
using System.Windows;
using System.Windows.Controls;
namespace myNameSpace
{ public partial class WPF_Xaml : Window
{ [STAThread] public static void Main()
{ new Application().Run( new WPF_Xaml() );
}
public WPF_Xaml() //constructor
{ InitializeComponent();
}
private void button1Click( Object sender, EventArgs e )
{ textBox.Text = "WPF Windows Program in XAML + C#. Resize!";
}
private void button2Click( Object sender, EventArgs e )
{ textBox.Text = "";
}
}
}
Click Debug → Start Without Debugging Ctrl F5.
Click the Talk!-button and resize the window.
| top of page: |