XAML
--------------------------------------------------------
CSS
------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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 wpf_kurs_v
{
///
/// Interaction logic for MainWindow.xaml
///
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void CommonClickHandler(object sender, RoutedEventArgs e)
{
FrameworkElement feSource = e.Source as FrameworkElement;
switch (feSource.Name)
{
case "YesButton":
MessageBox.Show( "Yes, yes , yes !" );
break;
case "NoButton":
MessageBox.Show( "Oh no !" );
break;
case "CancelButton":
MessageBox.Show( "But why ?? o_O" );
break;
}
e.Handled = true;
}
}
}
=====================================================================================
nazwa Routed Events
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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 RoutedEvents
{
///
/// Interaction logic for MainWindow.xaml
///
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void OnMouseDown(object sender, MouseButtonEventArgs e)
{
string message = "Sender: " + sender.ToString() + "\r\n" + "Source: " + e.Source + "\r\n" + "OriginalSource: " + e.OriginalSource + "\r\n";
listBox.Items.Add(message);
}
private void OnMouseUp(object sender, MouseButtonEventArgs e)
{
listBox.Items.Clear();
}
}
}
============================================================
przyklad na buble
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
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 RoutedEvents
{
///
/// Interaction logic for MainWindow.xaml
///
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void ButtonClickAttachedOnStackPanel(object sender, RoutedEventArgs e)
{
MessageBox.Show("Button Click Attached On StackPanel");
}
private void ButtonClickAttachedOnWindow(object sender, RoutedEventArgs e)
{
MessageBox.Show("Button Click Attached On Window");
}
private void ButtonClick1(object sender, RoutedEventArgs e)
{
MessageBox.Show("Original Button Click 1");
}
private void ButtonClick2(object sender, RoutedEventArgs e)
{
MessageBox.Show("Original Button Click 2");
}
}
}
http://msdn.microsoft.com/en-us/library/ms742806.aspx
http://www.wpftutorial.net/RoutedEvents.html
http://msdn.microsoft.com/en-us/library/ms752288.aspx
http://patryknet.blogspot.com/2010/07/dlaczego-warto-uzywac-dependency.html
http://msdn.microsoft.com/en-us/library/ms742550.aspx