WPF Learning Memo (1) draw a smiley face with WPF

Source: Internet
Author: User

1. Draw a smiley face for everyone to entertain:

<canvas width= "height=" 180 verticalalignment= "Center" margin= "772,577,466,390" >
            <ellipse canvas.left= "canvas.top=" width= "160" height= "160"
                     fill= "yellow" stroke= "Black"/> <ellipse
            canvas.left= "canvas.top=" "width=" "height=" fill= "Black"/> <ellipse
            "110" canvas.top= "width=" "height="
                     fill= "Black"/> <path data=
            "M 50,100 A 30,30 0 0 0 130,100" stroke= "B Lack "/>
        </Canvas>

The effect is as follows:

2.Xaml Date format

<label content= "{Binding taskdate,stringformat= ' yyyy-mm-dd '}" grid.column= "3"/>

3. Let the button have the feeling of a button, sweat, not nonsense, is to let the button has the feeling of press down

<ControlTemplate.Triggers>
                        <trigger property= "button.ispressed" value= "True" >
                            <setter property= "RenderTransform" >
                                <Setter.Value>
                                    <scaletransform scalex= ". 9" scaley= ". 9"/>
                                </Setter.Value>
                            </Setter>
                            <setter property= "Rendertransformorigin" value= "5,.5"/>
                        </Trigger>
                    </ControlTemplate.Triggers>

How to use 4.Popup

The 1.Popup control is never automatically displayed, and the IsOpen property must be set to display the popup control.

2. By default, the Popup.staysoen property is set to True and the Popup control is displayed until the IsOpen property is explicitly set to False.

If you set the Popup.staysopen property to False, the popup control disappears when the user clicks the mouse elsewhere.

If the IsOpen property of the popup control is set to True, you can set the popup control's display by the Popupanimation property of the popup control.

Because the popup control is not associated with any controls, it doesn't matter where the popup label is defined.

3. The associated control can do this:

placementtarget= "{Binding elementname=button1}"//binding on which control, this is and Button1 this control binding
placement= "Bottom"/ Displayed at the control's location, this is displayed below the Button1 control

Small example:

<popup popupanimation= "Fade"
                       placement= "Center"
                       name= "_pupup" >
                    <button>hello</button >
                </Popup>

The difference between 5.RenderTransform and LayoutTransform

The only difference between RenderTransform and LayoutTransform is when the transform is applied,

RenderTransform before rendering, and the latter is applied before layout. First look at the RenderTransform:

<stackpanel background= "Gainsboro" width= "height=" orientation= "horizontal" margin= "366,220,12,221" >
            <button width= "content=" >
                <Button.RenderTransform>
                    <rotatetransform angle= "15" ></RotateTransform>
                </Button.RenderTransform>
            </Button>
            <button width= "75" Content= ">
                <Button.RenderTransform>
                    <rotatetransform angle=" "></rotatetransform" >
                </Button.RenderTransform>
            </Button>
            <button width= "content=" >
                <Button.RenderTransform>
                    <rotatetransform angle= ></RotateTransform>
                </ button.rendertransform>
            </Button>
        </StackPanel>

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.