I'm starting with the WPF world and I want to create a XAML User Control, the problem is that I want the user control not to be a rectangular box inside which there are elements, etc; instead I want it to be a shape, actually a polygon.
Right now I'm trying with any polygon:
<UserControl x:Class="WpfControlLibrary1.UserControl1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:WpfControlLibrary1"
mc:Ignorable="d" Height="224" Width="435" Opacity="10">
<Path Data="M-70.616296,46.859802 L7.3270039,-1.2587545 174.31959,52.958763 168.71134,98.185567 z" Fill="#FF2121D6" HorizontalAlignment="Left" Height="100" Margin="138,114,0,0" Stretch="Fill" Stroke="Black" VerticalAlignment="Top" Width="246"/>
And I'm playing with the Opacity property, to try to make everything that surrounds the polygon transparent, but I can't find a way to do it, since what it does is make the entire control transparent when what I want is that what is inside of Path Data is displayed.
If anyone knows how to achieve this I would be very grateful if you could help me. All the best.
Let's see, you can achieve what you want in several ways, here I leave you a very simple one.
The template for a UserControl would look like this:
And to apply it like this, beware that you have to give it a Background to notice its shape:
Now, you can achieve better things with more time but I think this answers your question, I put some Triggers so you know how to integrate them.
All the best.