The class
System.Windows.UIElement (from which
UserControl indirectly derives) has a dependency property called
IsMouseOver. You could use a Trigger in your .xaml-file for setting the border color depending on the value (
True/False) of this property.
Here ist a good explanation how to achieve this behaviour:
http://www.wpf-tutorial.com/styles/trigger-datatrigger-event-trigger/
Edit:
I've made an example which works by only using Triggers:
<Window x:Class="BorderColor.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<UserControl BorderThickness="3">
<UserControl.Style>
<Style TargetType="UserControl">
<Setter Property="BorderBrush" Value="Blue"></Setter>
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="BorderBrush" Value="Red" />
</Trigger>
</Style.Triggers>
</Style>
</UserControl.Style>
<Grid>
<TextBlock Text="Hello!" FontSize="28" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" TextAlignment="Justify">
</TextBlock>
</Grid>
</UserControl>
</Window>
The important thing here is, that the border of the UserControl itself is used instead of an extra border. Additionally, the whole UserControl has to be filled with content (therefore the alignments of the TextBox are set to
Stretch). So, you can put inside the Grid whatever you want, just make sure all the available space of the UserControl ist used/filled.
I hope this is what you wanted to achieve.
Edit 2:
To avoid those "empty spaces", you could e.g. insert an empty label in your grid with the appropriate row and column spans. A simple example (without row or column definitions):
<Grid>
<Label Width="Auto" Height="Auto"></Label>
<TextBlock Text="Hello!" FontSize="28" HorizontalAlignment="Center" VerticalAlignment="Center" TextAlignment="Center">
</TextBlock>
</Grid>