private void button1_click(object sender, RoutedEventArgs e)private voidなメソッドとしてイベントハンドラのメソッドは用意されるのですね。引き数にはobjectとRoutedEventArgsというものが渡されています。objectは、イベントが発生したコントロール(ここではButton)を示すオブジェクトです。またRoutedEventArgsは、発生したイベントに関する情報を扱うためのオブジェクトになります。
textblock1.Text = "Hello, " + textbox1.Text + "!";シンプルですね。これを書いたら、実際にアプリを実行してみましょう。入力フィールドに名前を書いてボタンをクリックすると、「Hello, ○○!」とテキストが表示されます。
※リストが表示されない場合
AddBlockなどの広告ブロックツールがONになっているとリストなどが表示されない場合があります。これらのツールをOFFにしてみてください。
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.InteropServices.WindowsRuntime; using Windows.Foundation; using Windows.Foundation.Collections; using Windows.UI.Xaml; using Windows.UI.Xaml.Controls; using Windows.UI.Xaml.Controls.Primitives; using Windows.UI.Xaml.Data; using Windows.UI.Xaml.Input; using Windows.UI.Xaml.Media; using Windows.UI.Xaml.Navigation; namespace MyWin8App { public sealed partial class MainPage : Page { public MainPage() { this.InitializeComponent(); } private void button1_click(object sender, RoutedEventArgs e) { textblock1.Text = "Hello, " + textbox1.Text + "!"; } } }
<< 前へ | 次へ >> |