How to make a transparent Silverlight button when displaying an image?

I have a button that is programmed automatically, this is the contents of the stack panel with an image and a text block. This all works great.

I want to make the button behind the image and text transparent so that the image and text look as if they are sitting in the background, but still have all the properties of the button (i.e., someone clicks in the area of ​​the buttons that he still registers the event button clicks).

I played with opacity, but every opacity that I play when working with a button seems to set the entire button (image and text) for that opacity value.

How to make the button opaque while the contents of the text and image are still visible?

Oh, this is silverlight 3. Thanks in advance.

+3
source share
2 answers

You will need to create a button template and remove the gradients, focus element, etc. that you do not want to use for the default style for the button. It looks like you probably just want to save the presentation of the content and get rid of the background and mouse over the "glow" gradients. You will probably need to set the background of your StackPanel content transparent if you want the entire button area to capture mouse events, not just the main image and text content.

Scott Gu has a good tutorial here about the basics of creating a management template.

Expression Blend, " " → " ", , Blend.

+4

, , :

<Button>
        <Button.Template>
            <ControlTemplate TargetType="Button">
            <Grid />
        </ControlTemplate>
    </Button.Template>
</Button>

, .

+4

Source: https://habr.com/ru/post/1737087/


All Articles