SORU
30 HAZİRAN 2009, Salı


Nasıl bir düğme Yakın komut bağlamak için

En kolay yolu ButtonClick olay işleyicisi uygulamak ve Pencereyi çağırmak için.() Yakın bir yöntem. Ama nasıl bir komut bağlama ile bunu yapmak için?

CEVAP
30 HAZİRAN 2009, Salı


Tüm bu alır XAML biraz

<Window x:Class="WCSamples.Window1"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Window.CommandBindings>
        <CommandBinding Command="ApplicationCommands.Close"
                        Executed="CloseCommandHandler"/>
    </Window.CommandBindings>
    <StackPanel Name="MainStackPanel">
        <Button Command="ApplicationCommands.Close" 
                Content="Close Window" />
    </StackPanel>
</Window>

Ve C biraz#...

private void CloseCommandHandler(object sender, ExecutedRoutedEventArgs e)
{
    this.Close();
}

(this MSDN article uyarlanmıştır)

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • ELawshea

    ELawshea

    26 Mayıs 2008
  • tunez4you

    tunez4you

    20 EKİM 2008
  • Virtual Riot

    Virtual Riot

    19 Mayıs 2011