#:sdk Microsoft.NET.Sdk #:property TargetFramework=net10.0-windows #:property UseWPF=true #:property OutputType=WinExe #:property PublishAot=false using System; using System.Windows; using System.Windows.Controls; static class Program { [STAThread] static void Main() { var count = 0; var label = new TextBlock { Text = "Count: 0", VerticalAlignment = VerticalAlignment.Center, Margin = new Thickness(10) }; var dec = new Button { Content = "-", Width = 40 }; var inc = new Button { Content = "+", Width = 40 }; dec.Click += (_, _) => label.Text = $"Count: {--count}"; inc.Click += (_, _) => label.Text = $"Count: {++count}"; var row = new StackPanel { Orientation = Orientation.Horizontal, HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center, }; row.Children.Add(dec); row.Children.Add(label); row.Children.Add(inc); new Application().Run(new Window { Title = "Counter Example", Width = 640, Height = 420, Content = row, }); } }