Answer the question
In order to leave comments, you need to log in
How to round corners on a WPF element?
Good afternoon, comrades.
The question arose, how to round the corners of the elements? Buttons, Gryds, etc.
In general, a very common task, but you can’t figure it out without half a liter.
By the way, how good is the practice to cut interfaces in Blend?
Thank you.
Answer the question
In order to leave comments, you need to log in
The best way is to manually draw the element template. The same button, for example.
The first link I came across with a sane example:
https://professorweb.ru/my/WPF/Template/level17/17...
General point:
You need to specify the Template parameter for the object whose corners you want to round.
This can be done as in the example on the page through a link to StaticResource, or in place by specifying
<Button.Template>
...
</Button.Template>
<ControlTemplate TargetType="Button">
. Well, or not Button, but the element that you want to issue. <Rectangle RadiusX="10" RadiusY="10">
, you can <Border CornerRadius="10">
- at your discretion. Don't forget to add <ContentPresenter>
to display the content of the button (its text or any other elements that should be placed on it). In reality, you will have to add coloring depending on the state later (active, cursor hovered, cursor not hovered), and possibly an animation of the transition between these states! Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question