WPF notes (read the first-line farm 8-day introductory WPF)

Source: Internet
Author: User

WPF notes (read the first-line farm 8-day introductory WPF)

Basic ****************
Introducing Namespaces xmlns:local= "Clr-namespace:datatemplate"
StaticResource static resource equals constant, post-compilation value does not change {StaticResource Resourcekey=mystyle}
DynamicResource dynamic resource equals variable, post-compilation value can be changed {DynamicResource Resourcekey=mystyle}
Binding bindings text= "{Binding elementname=textbox1, Path=text}"
TemplateBinding Template Bindings

The

**************** style style****************
style is primarily for appearance mend, color, font size, and so on
style like CSS
TargetType define the appearance of a class of controls <style targettype= "button";
x:key defines an ID for a separate call <style x:key= "MyStyle" targettype= "button";
Baseon inherits <style x:key= "Childstyle" targettype= "button" basedon= "{StaticResource resourcekey=basestyle}";
Triggers triggers define what happens when a specific event occurs
MultiTrigger defines how a particular event should look when it occurs
DataTrigger define the appearance of a control in a specific state, such as checked
of radio Multidatatrigger defines the appearance of a control when multiple states exist at the same time

The

**************** template template****************
Template re-defines the appearance of the control, subverting the original appearance (and of course, inheriting it)
ControlTemplate template controls the appearance of the control < ControlTemplate x:key= "rect" targettype= "{x:type CheckBox}";
ContentPresenter inherit control original template Properties <contentpresenter /> Margin bound to Padding<contentpresenter margin= "{TemplateBinding Padding}"/>
Trigger templates can also have triggers
Style and ControlTemplate can be mixed using the
DataTemplate template to control how the data is displayed <datatemplate x:key= "rect";
Itemspaneltemplate Template Control Entry control Listbox,menu,statusbar such as <itemspaneltemplate x:key= "items";
Hierarchicaldatatemplate templates control hierarchical data structure controls

**************** data-bound ****************
control to a control's binding text= "{Binding elementname=scrollbar1, Path=value, mode= OneWay} "
Binding mode has four types
1:oneway source affects target, but target does not affect source. The
2:onewaytosource target affects the source, but the source does not affect the target. The
3:twoway source interacts with target. The
4:onetime extends a OneTime on oneway basis and binds only once.
.net object bound to control
list<student> List = new list<student> ();
List. ADD (New Student () {Name = "HxC", age = 20});
Listview1.itemssource = list;
<gridviewcolumn header= "name" displaymemberbinding= "{Binding Name}"/>
Note the use of IValueConverter, you can control the specific line color, and so on, specifically using the search IValueConverter
.net method and Control binding
public class Student
{
// The method to be referenced by the foreground
public string GetName ()
{
Return "line Code Farm";
}
}
<objectdataprovider x:key= "Test" objecttype= "{x:type local:student}" methodname= "GetName" ></ Objectdataprovider>
<textblock text= "{Binding source={staticresource resourcekey=test}, Mode=OneWay}"/
Validating Data
implements the ValidationRule interface, and then writes the custom validation logic

Elaborate control ****************
Content controls are all based on ContentControl,
One, Buttonbase:1.button,2.repeatbutton (repeat click event), 3.gridviewcolumnheader,4.togglebutton (Radio,check)
Second, Headeredcontentcontrol:1.expander,2.groupbox,3.tabitem
The tooltip cannot be used independently as a control, but is used in conjunction with the tooltip of other specific controls. The Tooltipserivce class, which can be used to design the relative position of the ToolTip display, prompting time
Iv. ScrollViewer
Entry control inherits from ItemsControl two important properties items (itemcollection type) and ItemsSource (IEnumerable type)
First, Menubase:1.menu,2.contextmenu
Second, Selector:1.listbox,2.combobox,3.tabcontrol,4.listview
Third, StatusBar
Iv. the TreeView
Text Control Textbox,richtextbox,passwordbox
The range control is based on rangebase, important attributes Largechange,smallchange,maximum,minimum
First, ScrollBar
Linkage <scrollbar name= "test" orientation= "horizontal" maximum= "minimum=" 5 "smallchange=" 2 "height=" Width= "186 "/>
<textbox name= "Txtscrollvalue" text= "{Binding elementname=test, path=value}"/>
Second, ProgressBar isindeterminate=true (infinite Scroll progress bar)

Painting Brush ****************
Based on brush, important attribute Opacity,relativetransform,transform
SolidColorBrush Solid Painting Brush
Gradientbrush Gradient Paint Brush
1:lineargradientbrush (linear gradient paint brush)
<Rectangle.Fill>
<lineargradientbrush startpoint= "0,0" endpoint= "1,0" >
<gradientstop color= "Yellow" offset= "0.5"/>
<gradientstop color= "Green" offset= "1"/>
</LinearGradientBrush>
</Rectangle.Fill>
2:radialgradientbrush (Round gradient brush)
<Rectangle.Fill>
<radialgradientbrush gradientorigin= "0.5,0.5" center= "0.5,0.5" radiusx= "0.5" radiusy= "0.5" >
<RadialGradientBrush.GradientStops>
<gradientstop color= "Yellow" offset= "0"/>
<gradientstop color= "Red" offset= "0.25"/>
<gradientstop color= "Blue" offset= "0.75"/>
<gradientstop color= "Limegreen" offset= "1"/>
</RadialGradientBrush.GradientStops>
</RadialGradientBrush>
</Rectangle.Fill>
TileBrush
1:imagebrush (Image painting brush)
<Grid.Background>
<imagebrush x:name= "Landbrush" imagesource= "C:\Users\Administrator\Desktop\weibo\64512.gif"/>
</Grid.Background>
2:visualbrush (Control Brush) any control can be used as a paint brush
3:drawingbrush (Custom paint brush)

Supplemental ****************
UserControl (User control)
UserControl is similar to a window, you can combine several controls to become a user control for repeated use
ResourceDictionary (resource dictionaries) can share well-defined styles
Window life cycle Initialized,activated,loaded,contentrendered,deactivated,gotfocus,lostfocus,gotkeyboardfocus, Lostkeyboardfocus,closing,closed
Property Change Notification (INotifyPropertyChanged)
dependency property (DependencyProperty)

WPF notes (read the first-line farm 8-day introductory WPF)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.