Pravesh Singh
Pravesh Singh

Reputation: 324

How to make custom close button in wpf?

I want to create following form but problem is there when I'm setting the margin with negative value then it will not work and hide my cross image. Is this possible to create as it is? or any other way to create this form.

My need: (in below image black area is transparent)

enter image description here

But now show my form like below image:-

enter image description here

Please let me know appropriate way.

Upvotes: 0

Views: 530

Answers (1)

AkselK
AkselK

Reputation: 2593

You can't draw outside of your application, without using Adorners or Popups, as Akku says in the comments.

But what you can do is to, instead of making margins negative, make them positive. So that your content (the gradient background), have a margin of 10 or 20 (or whatever number that produces the right amount of spacing.

<Window (.....) AllowsTransparency="True" WindowStyle="None">
    <Grid>
       <Button VerticalAlignment="Top" HorizontalAlignment="Right" Height="15" Width="15"/>
       <Border Margin="15">
            <YOUR_CONTENT>
       </Border>
    </Grid>
</Window>

Upvotes: 1

Related Questions