Close icon design mainly involves the main points of knowledge:
1, path, through path to draw lines. Of course, the general level, vertical can also be used rectangle/border and other alternative
Some simple line icons are easy to do with path.
2. Simple animation, animation usage
The button style is as follows:
<Buttonx:name= "Btnclose"Click= "Btnclose_onclick"> <button.template> <ControlTemplateTargetType= "button"> <Grid> <Gridx:name= "Uc_grid"VerticalAlignment= "Center"Height= "+"Width= "+"> <Pathx:name= "Uc_path1"Stroke= "DodgerBlue"strokethickness= "4"Data= "m0,0 l20,20"VerticalAlignment= "Center"HorizontalAlignment= "Center"></Path> <Pathx:name= "Uc_path2"Stroke= "DodgerBlue"strokethickness= "4"Data= "m20,0 l0,20"VerticalAlignment= "Center"HorizontalAlignment= "Center"></Path> <Grid.rendertransform> <RotateTransformx:name= "Uc_transform"Angle= "0"CenterY= "12.5"CenterX= "12.5"></RotateTransform> </Grid.rendertransform> </Grid> <ContentPresenterContent="{TemplateBinding Content}"HorizontalAlignment="{TemplateBinding HorizontalAlignment}"></ContentPresenter> </Grid> <controltemplate.triggers> <Trigger Property= "IsMouseOver"Value= "True"> <SetterTargetName= "Uc_path1" Property= "Data"Value= "m0,0 l22,22"></Setter> <SetterTargetName= "Uc_path2" Property= "Data"Value= "m22,0 l0,22"></Setter> </Trigger> <Trigger Property= "IsPressed"Value= "True"> <SetterTargetName= "Uc_path1" Property= "Data"Value= "m0,0 l24,24"></Setter> <SetterTargetName= "Uc_path2" Property= "Data"Value= "m24,0 l0,24"></Setter> </Trigger> <EventTriggerRoutedEvent= "MouseEnter"> <BeginStoryboardHandoffBehavior= "Snapshotandreplace"> <StoryboardTargetName= "Uc_transform"TargetProperty= "Angle"> <DoubleAnimation from= "0" to= "All"Duration= "0:0:0.1"></DoubleAnimation> </Storyboard> </BeginStoryboard> </EventTrigger> </controltemplate.triggers> </ControlTemplate> </button.template> </Button>
View Code
WPF Custom Window Close button