Techniques learned:
Routed input event
XAML
Finished some example code about XAML and learned the routed event.
Technique Summary:
1, first I want to make a summary about the hierarchical tree about event in WPF, the relationship are about as following:
Object
EventArgs
RoutedEventArgs
inputEventArgs
KeyBoardEventArgs
……
MouseEventArgs
……
StylusEventArgs
……
In WPF, there many routed events. Routed events are events that are designed to work well with a tree of elements. When a routed event is raised, it can travel up or down the visual and logical tree.
2, XAML is a very usefully tool in WPF, in most cases, it’s used to initialize object and define their properties. Like the constructor in c#.
Code related:
I: using the XAML programming.
<Window xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation”
Title=”About WPF Unleashed” SizeToContent=”WidthAndHeight”
Background=”OrangeRed”>
<StackPanel>
<Label FontWeight=”Bold” FontSize=”20” Foreground=”White”>
WPF Unleashed (Version 3.0)
</Label>
<Label>© 2006 SAMS Publishing</Label>
<Label>Installed Chapters:</Label>
<ListBox>
<ListBoxItem>Chapter 1</ListBoxItem>
<ListBoxItem>Chapter 2</ListBoxItem>
</ListBox>
<StackPanel TextElement.FontSize=”30” TextElement.FontStyle=”Italic”
Orientation=”Horizontal” HorizontalAlignment=”Center”>
<Button MinWidth=”75” Margin=”10”>Help</Button>
<Button MinWidth=”75” Margin=”10”>OK</Button>
</StackPanel>
<StatusBar>You have successfully registered this product.</StatusBar>
</StackPanel>
</Window>
Ii: using the c# programming.
StackPanel panel = new StackPanel();
TextElement.SetFontSize(panel, 30);
TextElement.SetFontStyle(panel, FontStyles.Italic);
panel.Orientation = Orientation.Horizontal;
panel.HorizontalAlignment = HorizontalAlignment.Center;
Button helpButton = new Button();
helpButton.MinWidth = 75;
helpButton.Margin = new Thickness(10);
helpButton.Content = “Help”;
Button okButton = new Button();
okButton.MinWidth = 75;
okButton.Margin = new Thickness(10);
okButton.Content = “OK”;
panel.Children.Add(helpButton);
panel.Children.Add(okButton);
..
posted @ 2008-09-06 17:00 大侠赵敏 阅读(169) 评论(0)
编辑