Perfect removal of the borders of WPF buttons

Source: Internet
Author: User

Main Page back picture,

Add 5 function buttons and set button background and borderbrush to transparent, as if no problem, run effect

Not only has a glowing border, but when the mouse passes, the button is not transparent,

Solution 1: Set opacity to 0

Run effect

and a picture yes, perfect solution.

If there are no special requirements, you can simply set a sentence, you can remove the border

Solution 2:

1<button content="Forgot your password? "canvas.left="910"canvas.top="357"Width="154"height=" +"Background="Transparent"Foreground="#FF59A4A9"2borderthickness="0"Fontsize=" -"Name="Laforgetpassword"click="Laforgetpassword_click"style="{StaticResource {x:static Toolbar.buttonstylekey}}">
View Code

But when the mouse passes, it still shows a big button.

If you want to completely remove the border, and when the mouse will not be the original, then only the rewrite button ControlTemplate

Solution 3:

1<controltemplate x:key="Returnbutton"Targettype="{x:type Button}">2<Grid>3<Rectangle>4<Rectangle.Fill>5<imagebrush imagesource="/images/btngreynomal.png"></ImageBrush>6</Rectangle.Fill>7</Rectangle>8<contentpresenter verticalalignment="Center"Horizontalalignment="Center"Content="{TemplateBinding Content}"></ContentPresenter>9</Grid>Ten</ControlTemplate>
View Code

Add Reference

Ok!!!!!

If you also need to change the background picture of the button according to the condition, my solution is (obviously a bit stupid, also look at the point) in rewriting a ControlTemplate, replace the ImageSource,

Replace the template of the button when the condition is met, the code

Name.template = (ControlTemplate) Application.Current.TryFindResource ("Key of the resource") of the IF (condition satisfied) button;

Run

When conditions are met

Perfect removal of the borders of WPF buttons

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.