方法 : 読み込まれたイベントを処理する

更新 : 2007 年 11 月

この例では、FrameworkElement.Loaded イベントを処理する方法と、このイベントの処理に適したシナリオを示します。ページが読み込まれると、ハンドラは Button を作成します。

使用例

次の例では、Extensible Application Markup Language (XAML) を分離コード ファイルと共に使用します。

<StackPanel
  xmlns="https://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="https://schemas.microsoft.com/winfx/2006/xaml"
  x:Class="SDKSample.FELoaded"
  Loaded="OnLoad"
  Name="root"
>
</StackPanel>
Private Sub OnLoad(ByVal sender As Object, ByVal e As RoutedEventArgs)
    Dim b1 As Button = New Button()
    b1.Content = "New Button"
    root.Children.Add(b1)
    b1.Height = 25
    b1.Width = 200
    b1.HorizontalAlignment = HorizontalAlignment.Left
End Sub
void OnLoad(object sender, RoutedEventArgs e)
{
    Button b1 = new Button();
    b1.Content = "New Button";
    root.Children.Add(b1);
    b1.Height = 25;
    b1.Width = 200;
    b1.HorizontalAlignment = HorizontalAlignment.Left;
}

サンプル全体については、「Loaded イベントのサンプル」を参照してください。

参照

概念

オブジェクトの有効期間イベント

ルーティング イベントの概要

参照

FrameworkElement

その他の技術情報

基本要素に関する「方法」トピック

基本要素のサンプル