using System;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
namespace SayHello
{
class FormatTheButton:Window
{
private Run runbutton;
[STAThread]
public static void Main()
{
Application app = new Application();
app.Run(new FormatTheButton());
}
public FormatTheButton()
{
Title = "Format The Button";
Button btn=new Button();
btn.HorizontalAlignment=HorizontalAlignment.Center;
btn.VerticalAlignment=VerticalAlignment.Center;
btn.MouseEnter+=ButtonOnMouseEnter;
btn.MouseLeave+=ButtonOnMouseLeave;
Content = btn;
TextBlock txtblk=new TextBlock();
txtblk.FontSize = 24;
txtblk.TextAlignment=TextAlignment.Center;
btn.Content = txtblk;
txtblk.Inlines.Add(new Italic(new Run("Click")));
txtblk.Inlines.Add(" the");
txtblk.Inlines.Add(runbutton=new Run("button"));
txtblk.Inlines.Add(new LineBreak());
txtblk.Inlines.Add("to lauch the");
txtblk.Inlines.Add(new Bold(new Run("rocket")));
}
void ButtonOnMouseEnter(object sender, MouseEventArgs args)
{
runbutton.Foreground = Brushes.Red;
}
void ButtonOnMouseLeave(object sender, MouseEventArgs args)
{
runbutton.Foreground = SystemColors.ControlTextBrush;//不知道这行代码什么意思
}
}
}