using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
public class MainClass : Window
{
[STAThread]
public static void Main()
{
Application app = new Application();
app.Run(new MainClass());
}
public MainClass()
{
Button btn = new Button();
btn.HorizontalAlignment = HorizontalAlignment.Center;
btn.VerticalAlignment = VerticalAlignment.Center;
btn.Click += ButtonOnClick;
Content = btn;
StackPanel stack = new StackPanel();
btn.Content = stack;
Polyline poly = new Polyline();
poly.Stroke = SystemColors.ControlTextBrush;
poly.Points = new PointCollection();
for (int x = 0; x <= 100; x += 10)
poly.Points.Add(new Point(x, (x + 10) % 20));
stack.Children.Add(poly);
Uri uri = new Uri("pack://application:,,/BOOK06.ICO"); // 32-pixels
BitmapImage bitmap = new BitmapImage(uri);
Image img = new Image();
img.Margin = new Thickness(0, 10, 0, 0);
img.Source = bitmap;
img.Stretch = Stretch.None;
stack.Children.Add(img);
}
void ButtonOnClick(object sender, RoutedEventArgs args)
{
MessageBox.Show("The button has been clicked", Title);
}
}
|