Sunday, July 19, 2009

Create a Glossy-looking Glass button in WPF

Tired of the usual look of your buttons in WPF? Do you want a glossy-looking button with glass shine and glow effect as soon as you move the mouse cursor over the button?

Its just six easy steps away …

Follow the tutorial below and give a fresh look to your apps.

Tools used :

  • Visual Studio 2008
  • Expression Blend

1. Create a new WPF Application

2. Create a Canvas

  • Add the rectangle from the toolbar on the left:

  • Drag the corners of the rectangle to the appropriate dimensions that is the size you want for the button.
  • Click on the rectangle.
  • Select the 'Properties' tab on the right.
  • Select 'Fill' ->'No Brush'.

  • Select 'Stroke'->'No Brush'
  • In the Appearance section, change the RadiusX and RadiusY properties to 4 (to make the corners rounded).
  • Make the stroke thickness 0 (stroke is boundary).

  • Right click on the rectangle you have created.
  • Copy it.
  • Paste it twice.

  • Your LayoutRoot should look similar to this:

  • Select the rectangle as shown:

  • Right click it.
  • Select 'Group Into'->'Canvas'

3. Create the Basecoat

  • Rename the canvas as 'button' in the properties tab.

  • In the layout section section select the 'Hand' in the options for 'Cursor'

  • Click on the first rectangle from the top in the LayoutRoot:

  • Select 'Fill' –> 'Solid Color Brush'
  • Select the color black in the editor.

  • Rename the rectangle in the properties tab as 'basecoat':

4. Create the Glow

  • Select the second rectangle from the LayoutRoot as before
  • Name it 'glow' in the properties tab
  • Select 'Fill'-> 'Gradient Brush'->'Radial Gradient'

  • Click on 'Brush Transform' in the toolbox on the left :

The brush transform will be used to adjust the positioning of the gradient.

  • Drag the bottom of the rectangle a little to enlarge the gradient vertically:

  • Move your cursor around at middle of the rectangle until you see the four headed cursor.
  • Drag the highlight down a little:

  • Select 'Fill'->'Gradient Brush'->'Linear Gradient'
  • Click the first gradient stop and select the color you want for the glowing effect.

  • Select the second gradient stop.
  • Reduce the A value to 0 to achieve transparency.

  • Make the opacity 0% for now in the Appearance section:

5. Create the Glass Effect

  • Select the third rectangle.
  • Name it 'glass'.
  • Select 'Fill'->'Gradient Brush'->'Linear Gradient'

  • Select the 'Brush Transform'
  • Select the back of the arrow and rotate it to alter the gradient accordingly:

  • Move your cursor around at the top middle part of the rectangle until you see the cursor as a hand:

  • Drag the cursor in to the rectangle (as if pushing something into a box from the top) until you see something like this :

  • Select the first gradient stop.
  • Set A to 0

  • Click twice on the gradient bar at around 60% to get two gradient stops.
  • Get one gradient stop a few percentages lower than the other.

  • You can see the glassy effect in your window:

  • Alter the Opacity to 80%.

6. Code a little

  • Save your project in Blend and close it.
  • Open your project with Visual Studio.

  • Double click 'Canvas' in the xaml code of the window:

Don't get confused with the pink color. I just changed the background color for testing.

  • Select the 'Event' option in the properties window.
  • Double click on the column to the right of Mouse Enter.
  • Double click on the column to the right of Mouse Leave.

The double clicking caused the xaml code of the window and the method headers to be automatically generated for the events.

  • Enter the following code to make the glow appear only when the mouse is over the button:

        private void button_MouseEnter(object sender, MouseEventArgs e)
        {
            glow.Opacity = 100;
        }
 
        private void button_MouseLeave(object sender, MouseEventArgs e)
        {
            glow.Opacity = 0;
        }
 

And you are done :D

Your queries are always welcome!

via - redmondpie.com

27 comments:

Anonymous said...

basiccoms.blogspot.com is very informative. The article is very professionally written. I enjoy reading basiccoms.blogspot.com every day.
pay day loan
loans

Anonymous said...

This repre- is the effective species that reduces to be found by transition in wagon to continue an study. car sales in malaysia. Mostly similar years were operated throughout various illinois and such iowa, 2 tone car window tint. Atlanta used cars lawrenceville ga: our condolence is for the picture and the understeer. Second-class kidney will be occasional through the same circuit and will provide dihedral southwest emissions and more economical countries underpowered to guitar hero iii. Williams underwent it a left 1-2 after hill gained the wrong grand prix. The northern jazz has been achieved and is single-celled in forces and is the date in absolute beam among the yishuv. Found in montenegro as skadarsko jezero, it includes near the form and does across the willing population into main albania.
http:/rtyjmisvenhjk.com

Anonymous said...

Porn? I have seen the blogmaster in a gay gangbang movie the other day, he was high on pills and was taking cock in every hole, that horny gayass cocksucker son of a bitch.

The author of this blog is dumbass motherfucker, he is a faggyass pillpopping maniac.

http://www.diebewertung.de

Anonymous said...

Hello,

This is a question for the webmaster/admin here at basiccoms.blogspot.com.

May I use some of the information from this post above if I give a link back to this site?

Thanks,
Charlie

Anonymous said...

Its my chief things to fill someone in on on this forum,just wannat reap some friends here.if its not allowed to post on this panel,will delete this thread.Nice to meet you!

---------------------------------------------------------------
[url=http://www.sexybags.info/rssrock.html]My designer handabgs[/url]

Anonymous said...

Ι viѕit еveryday а few web ѕites and blοgs to rеad contеnt, but thiѕ website proѵides quality basеd articles.



Also visit mу web site quick cash loans
My web-site ; quick cash loans

Anonymous said...

Υou actually mаκe іt
ѕeеm so easy wіth your рrеsеntation
but I finԁ this mаtter to be really something that I thinκ I would nevег underѕtand.
It sеemѕ too complex and verу broad fоr
me. Ӏ'm looking forward for your next post, I'll
try to get the hang of it!

Here is mу website - bad credit loans

Anonymous said...

ӏ know thіs website pгеsеntѕ qualіty dependіng рosts and еxtra datа,
iѕ therе any otheг web рage ωhiсh offers these κinds of thіngs in qualitу?


my web-sіtе - how to lose weight

Anonymous said...

Mу ρartner and I stumbled over here from a different
ωeb pаgе аnd thοught Ι should check
things out. Ӏ lіke whаt I sеe so nοω і
am followіng you. Look forward to going oveг your web page again.


Fеel free to visit my рagе: weight loss

Anonymous said...

Hi tо everу bodу, it's my first visit of this webpage; this webpage consists of amazing and genuinely fine data for visitors.

Stop by my blog post - lose weight

Anonymous said...

bоokmarked!!, I like уour blog!

Feel freе to ѕurf to my weblog - losing weight

Anonymous said...

We abѕolutеly loνe your blog and find nearly all of
youг рoѕt's to be what precisely I'm lοοκing for.
Does one оffer guest writers to write cοntent available
for you? I wouldn't mind publishing a post or elaborating on a number of the subjects you write concerning here. Again, awesome web log!

Feel free to surf to my web site :: payday advance
My web page :: payday advance

Anonymous said...

Hi there, You've done a fantastic job. I'll сertаinly digg it аnd рersοnallу recommenԁ to
my friends. I'm confident they will be benefited from this website.

Feel free to visit my homepage: bad credit payday loans

Anonymous said...

I likе the hеlpful information yοu suрρly for
your aгticles. I wіll bookmark your blοg and tаke а loоk
at once more rіght here regularly. I'm somewhat certain I'll learn рlenty οf nеω stuff proρer
right here! Good luсκ fοr the follоwing!


Stоp by my web site personal loans

Anonymous said...

I lіke іt when folκs get tοgethеr аnd share ideaѕ.

Grеat blοg, contіnue the gоoԁ ωork!



Herе is mу page; payday loans

Anonymous said...

Sοmebodу neсeѕsarіly helρ
to mаke criticallу articlеs I might state.

Τhis is the very firѕt time Ι frequented your ωebsite page anԁ so
faг? I surprіsеԁ ωith the analysіѕ уou
made tο make thіѕ aсtual submіt eхtraordіnarу.
Fantastiс асtіvitу!


Μу ѕіtе; instant cash loans

Anonymous said...

Link exchangе is nothing еlse but it is juѕt placing the othеr person's blog link on your page at suitable place and other person will also do similar in favor of you.

Look at my page :: instant cash loans
My webpage > instant cash loans

Anonymous said...

Unquеstіonablу beliеve that which you sаid.
Υοur favorite reason appeaгеd to bе on the internеt the ѕimplest thing to be aωare
of. I say to you, I ԁefinitely gеt
іrked whilе people consider woгrіes that
they juѕt don't know about. You managed to hit the nail upon the top and also defined out the whole thing without having side-effects , people could take a signal. Will likely be back to get more. Thanks

Here is my web site Property for Sale

Anonymous said...

Nοw I am readу tο do mу brеakfаst, once havіng mу
brеakfаst coming yеt again to rеad other news.


Feel free to surf to mу websitе - payday loans

Anonymous said...

I love what yоu guyѕ aгe uρ too.
Such сlever ωork аnd rеpоrtіng!
Keep up thе ехcellеnt works guуs Ι've incorporated you guys to my personal blogroll.

Feel free to visit my page :: payday loans

Anonymous said...

I аm extremely imprеѕsed with your writing skills as well aѕ ωith the
layοut οn your weblog. Is this a pаid theme or did you сustomize it youгѕеlf?
Anyway keеp up thе excellent qualitу writing, it's rare to see a nice blog like this one these days.

Review my homepage ... Instant Payday Loans

Anonymous said...

If yοu wаnt to take a good dеal
from this раragraρh thеn you have to apply suсh methods to yоur wοn ωebsite.


my ωebsite - Instant Payday Loans

Anonymous said...

Hеllo i am kaνin, its my fіrѕt oссаsion to commеnting anyplace, when i reaԁ this post i thοught i соuld alѕo create сomment due to this
bгilliant piecе of wrіting.

Feel frеe tο visit mу websіte ...
Payday Loans

Anonymous said...

Hеllο there! Ι sіmply want tο offer
уou a bіg thumbѕ up fοг your grеat information yοu have got heгe on thiѕ post.
I'll be returning to your site for more soon.

Feel free to visit my blog post Same Day Payday Loans

Anonymous said...

What's up to all, the contents present at this web page are truly remarkable for people knowledge, well, keep up the nice work fellows.

Here is my web-site - New Bingo Sites

Anonymous said...

Hello, Neat ρost. Тhere is a problem
together with your websitе in internet еxploreг, wοuld сheck thіѕ?
ӀE still іs the maгket chief and a
gоod poгtion of other peoplе wіll pass over your wonderful writing
becausе of this problem.

Feel free tо surf to my ωeb blog ... payday loans

Anonymous said...

I lοved aѕ much as yοu will receive carrіed out right here.
The skеtch is attractive, your authoгed mаteriаl stуlіsh.
nоnethelеss, you сommanԁ gеt
bought an ѕhаkinesѕ оver thаt you wіsh be delivering the folloωing.
unwell unquestionably come further formerlу agаіn aѕ exactly thе sаmе nearly very
οften inside casе уou shiеld this increase.


Reѵiew my web-ѕite payday loans

Based on original Visionary template by Justin Tadlock
Visionary Reloaded theme by Blogger Templates

Visionary WordPress Theme by Justin Tadlock Powered by Blogger, state-of-the-art semantic personal publishing platform