Control belongs to one of the elements , It is generally used to interact with users . For example, it can receive some elements of keyboard or mouse input .

All controls inherit from Control class , Next, we will briefly introduce some properties of the control class in three points .

1, Background brush and foreground brush

All controls have background and foreground concepts . Background refers to the surface of the control , Foreground refers to text . stay WPF We use BackGround and Foreground Two properties to describe .

There are generally two ways to assign values to these two attributes , One is C# Code assignment , One is XAML Statement assignment .

1) Code assignment

We add a response function when we load the window , Click window , Found in its event Loaded Events to add .

Let's add a name button1 Button for , When loading through windows , Access the button , Set its background and foreground :
private void Window_Loaded(object sender, RoutedEventArgs e) { // Multiple assignment methods
//this.button1.Background = new SolidColorBrush(Colors.AliceBlue);
this.button1.Background = new SolidColorBrush(Color.FromRgb(0, 255, 0));
this.button1.Foreground = System.Windows.SystemColors.ControlDarkBrush; }
2)xaml Statement assignment

xaml Statement assignment is relatively simple , stay xaml In Button Access in property properties BackGround and Foreground Assign it a value .
<Button Content="Button" Background="AliceBlue" Foreground="Black" Height="23"
Name="button1" Width="75" />
2, typeface

Font properties include

* FontFamily: Type of font , For example, Song typeface , Blackbody, etc
* FontSize: Font size
* FontStyle: Display style of font , Like italics , Artistic style, etc
* FontWeight: The thickness of the font
* FontStrech: How stretched the font is
generally speaking , We can assign values to these properties directly in the property properties of the control .

3, Mouse cursor

The common function of the mouse cursor is to display the running status of the current program , Through the Cursor Property to set the shape of the mouse cursor .


©2019-2020 Toolsou All rights reserved,
It's unexpected Python Cherry tree (turtle The gorgeous style of Library )Unity3D of UGUI Basics -- Three modes of canvas os Simple use of module computer network --- Basic concepts of computer network ( agreement , system )html Writing about cherry trees , Writing about cherry trees Some East 14 Pay change 16 salary , Sincerity or routine ?Unity-Demo Examples ✨ realization UI- Backpack equipment drag function 06【 Interpretation according to the frame 】 Data range filtering -- awesome java Four functional interfaces ( a key , simple )