Reputation: 91
I want to create a simple border around certain controls to create a stylised panel. I've created the border around one control but now I want to create it in such away that I can reuse it on any other controls throughout the applications. I've created a User Control to do it but I was unable to get the User Control to resize to the contents. Is there a way to do the same thing in XAML e.g. with a ControlTemplate in Resources.xaml?
<Border Background="LightGray"
BorderBrush="DarkGray"
BorderThickness="1"
ClipToBounds="True"
Opacity="0.80">
<Border Background="#25FFFFFF"
BorderBrush="Black"
BorderThickness="1"
Margin="-2">
<Border.Effect>
<DropShadowEffect ShadowDepth="0" BlurRadius="10"/>
</Border.Effect><!--Any Control - Insert TextBlock, Button, ContentPresenter -->
</Border>
</Border>
Upvotes: 0
Views: 1493
Reputation: 5785
If I understand correctly, and the border provides no functional value, it is just a visual decoration you want to apply to certain controls, you may want to consider an Adorner.
One of the uses for an Adorner
is to apply a visual overlay to UIElements
, which sounds like your goal here. That MSDN Article also provides an example and a simple search will yield plenty of custom Adorner
examples.
Upvotes: 1