Aracılığıyla paylaş


Nasıl Yapılır: Yüklü Bir Olayı İşleme

This example shows how handle the FrameworkElement.Loaded event, and an appropriate scenario for handling that event. The handler creates a Button when the page loads .

Örnek

The following example uses Extensible Application Markup Language (XAML) together with a code-behind file.

<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;
}

Ayrıca bkz.

Başvuru

FrameworkElement

Kavramlar

Nesne Ömür Olayları

Yönlendirilmiş Olaylara Genel Bakış

Diğer Kaynaklar

Temel Öğeler Nasıl Yapılır Konuları