Search code examples
wpfwpftoolkit

How to create border for png image


I have a custom image in .png format. I want to create button. The form of button is this image. So I put the image inside button template and want it be fleshed only when mouse over the image. The shape of image is rectangle (http://prntscr.com/lz5m5q), but in fact it is custom shape. So how can I set border for button and ignore transparent background of image (I don't want see border as rectangle, border should be around my actual image).


Solution

  • hope i got correctly, is this you want ?

    Style Link

    due to characters limit i am posting style in above link. copy paste codes from above link in Windows.Resources or where you want.

    <Window.Resources>
        <!-- I put this in windows resources you can put it app.xaml or any resource dictionary -->         
        <!-- Copy here content from the above link link because of stackoverflow character limit i cant paste it here. -->        
    </Window.Resources>
    
    <Grid>
        <Button Height="250" Width="300" Style="{DynamicResource CountryButtonStyle}" />    
    </Grid>
    

    Output:

    Screenshot