HWH....

导航

 

1. Window derives from Control by way of ContentControl. Properties defined by Control include Background, Foreground, BorderBrush, BorderThickness, and font-related properties, such as FontWeight and FontStretch.

2. From Control descend more than 50 other classes, providing programmers with favorites such as buttons, list boxes, scroll bars, edit fields, menus, and toolbars.

Button

The archetypal control is the button, represented in the WPF by the Button class. The Button class has a property named Content and an event named Click that is triggered when the user presses the button with the mouse or keyboard.

That both Window and ButtonBase have the same Content property has a profound implication: All the varieties of objects that you can use as the content of a window can also be used as the content of a button. A button can display a bitmap, a Shape object, and formatted text. In fact, you can even set the Content property of one Button object to another Button object.

1. btn.Focus();

2. btn.IsDefault = true;

3. btn.IsCancel = true;

4. ButtonBase defines a property named ClickMode(enumate).

5. btn.Margin = new Thickness(96);

6. btn.HorizontalContentAlignment = HorizontalAlignment.Left;
    btn.VerticalContentAlignment = VerticalAlignment.Bottom;

7. btn.Padding = new Thickness(96);

8. The HorizontalAlignment and VerticalAlignment properties are set to HorizontalAlignment.Stretch and VerticalAlignment.Stretch by default.

9. btn.HorizontalAlignment = HorizontalAlignment.Center;
    btn.VerticalAlignment = VerticalAlignment.Center;

  Add upon two statements into program, and now the button's size is affacted solely(only) by the content of the button.







 


posted on 2011-04-12 17:08  HWH....  阅读(144)  评论(0编辑  收藏  举报