Alessandro Del Sole's Blog

/* A programming space about Microsoft® .NET® */

  Home :: Contact :: Syndication  :: Login
  1204 Posts :: 64 Stories :: 1555 Comments :: 251 Trackbacks

News

Your host

This is me! Questo spazio è dedicato a Microsoft® .NET®, di cui sono molto appassionato :-)

These postings are provided 'AS IS' for entertainment purposes only with absolutely no warranty expressed or implied and confer no rights.
If you're not an Italian user, please visit my English blog

Microsoft MVP

My MVP Profile

My MVP Corner Page

Il mio libro su VB2010!

Il mio nuovo libro su Visual Basic 2010 E' uscito il mio libro "Visual Basic 2010 Unleashed". Clicca sulla copertina per informazioni!

Visual Basic Tips & Tricks Team Member

Le vostre visite

I'm a VB!

Guarda la mia intervista a Seattle

Windows Live Alerts

Vsi Builder 2008

Il mio tool per VS 2005/2008 Scarica Vsi Builder, il mio tool per Visual Studio 2005/2008!

Aggiungimi al Social MSDN!

Dove vivo

Contattami su Messenger


Grab this badge here!

Guarda i miei webcast MSDN

CyberInstaller Beta Tester

Scarica il nuovo CIS 2009!!

Altri spazi

CodePlex download Scarica i miei progetti open-source su CodePlex!

Cerca nel blog



Seguimi su Twitter!

Article Categories

Archives

Post Categories

Image Galleries

.NET Framework

Back to basics

Blogroll

Help 1.x e 2.0

Microsoft & MSDN

Setup & Deployment

Visual Basic .NET e 2005

In Windows Presentation Foundation, the most of controls expose a property called OpacityMask which allows to create transparency areas along the object itself and diffuse those areas in different manners.

Let's see a practical sample on a Button. Start Visual Studio 2005 and create a new empty WPF project, then type the following XAML from within the Grid:

      <Button Width="220" Height="75">
        <Button.OpacityMask>
          <LinearGradientBrush >
            <GradientStop Color="Transparent" Offset="0"/>
            <GradientStop Color="Black" Offset="0.5"/>
            <GradientStop Color="Transparent" Offset="1"/>
          </LinearGradientBrush>
        </Button.OpacityMask>
        This is a button with OpacityMask
      </Button>

We can use Brush objects to apply a gradient transparency to the control. In the above code I inserted just three GradientStop, but if you want to see how transparencies change you can add some more. Moreover you could set StartPoint and EndPoint attributes to the LinearGradientBrush, modifying the starting and ending gradient points. Anyway the above code snippet is a good starting point to learn OpacityMask. This is the result it produces: 

As you can see, along the button appear some transparency areas (which are drawn by a Transparent color). This could be a nice effect in imaging apps.

Alessandro

posted on Sunday, October 14, 2007 12:42 PM

Feedback

No comments posted yet.

Post Feedback

Title:
Name:
Url:
Comments: 
Codice di sicurezza
Protected by FormShield