<StackPanel
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="WpfApplication1.RoutedEventSource">
<StackPanel.Resources>
<Style TargetType ="{x:Type Button}">
<Setter Property="Height" Value="30"/>
<Setter Property="Width" Value="100"/>
<Setter Property="HorizontalAlignment" Value="Left"/>
</Style>
</StackPanel.Resources>
<Button Click="HandleClick">Button 1</Button>
<Button Click="HandleClick">Button 2</Button>
<Button Click="HandleClick">Button 3</Button>
</StackPanel>
//File:Window.xaml.cs
using System.Windows;
using System.Windows.Controls;
namespace WpfApplication1 {
public partial class RoutedEventSource {
void HandleClick(object sender, RoutedEventArgs e)
{
Button srcButton = e.Source as Button;
srcButton.Width = 200;
}
}
}
|