2014年7月29日火曜日

とりあえず、プロジェクトを作る

とりあえず、Visual Studioで新しいソリューションを作成してみよう。
わたしはVisual Studio Express 2013 for Windows Desktopを使っています。

ソリューション名は、とりあえずHelloWorld。



WPFアプリとして作ってみよう。



サクッとプロジェクトが出来上がる。

ここで出来たファイルは
App.config
App.xaml
App.xaml.cs
MainWindow.xaml
MainWindow.xaml.cs
の5つ(.csは、xamlを展開すると出てくる)。

App.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
    </startup>
</configuration>

プロジェクトの環境が書いてあるようだ。



App.xaml
<Application x:Class="HelloWorld.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
         
    </Application.Resources>
</Application>

XAMLのベース。



App.xaml.cs
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;

namespace HelloWorld
{
    /// 
    /// App.xaml の相互作用ロジック
    /// 
    public partial class App : Application
    {
    }
}

相互作用ロジックとは耳慣れない言葉だが、アプリケーションクラスであるようだ。



MainWindow.xaml
<Window x:Class="HelloWorld.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        
    </Grid>
</Window>

メインウィンドウのXAML。



MainWindow.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace HelloWorld
{
    /// 
    /// MainWindow.xaml の相互作用ロジック
    /// 
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
    }
}

またもや相互作用ロジックだが
MainWindow.xamlのコードビハインドと言われる、c#を書くソース。

まずはここに、TextBlockで "Hello World" とでも表示させてみよう。
(次へ続く)

0 件のコメント:

コメントを投稿