//-------------------------------------------------- // ClickToMakeBigger.cs (c) 2006 by Charles Petzold //-------------------------------------------------- using System; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; namespace Petzold.ClickToMakeBigger { public class ClickToMakeBigger : Window { [STAThread] public static void Main() { Application app = new Application(); app.Run(new ClickToMakeBigger()); } public ClickToMakeBigger() { Title = "Click to Make Bigger"; Width = 192; Height = 192; WindowStartupLocation = WindowStartupLocation.CenterScreen; DataContext = this; // Make WrapPanel content of window. WrapPanel wrap = new WrapPanel(); Content = wrap; // Create TextBlocks to display window properties. foreach (string prop in new string[] { "Width", "Height", "ActualWidth", "ActualHeight" }) { TextBlock txtblk = new TextBlock(); txtblk.SetBinding(TextBlock.TextProperty, prop); wrap.Children.Add(new TextBlock(new Run(prop + "="))); wrap.Children.Add(txtblk); wrap.Children.Add(new TextBlock(new Run(" "))); } } protected override void OnMouseDown(MouseButtonEventArgs args) { Width = ActualWidth + 1; Height = ActualHeight + 1; } } }