I have a WPF user control with following xaml
<UserControl x:Class="Scheduler.ItemBox"
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"
mc:Ignorable="d"
d:DesignHeight="40" d:DesignWidth="150" MinHeight="40" MinWidth="75" VerticalAlignment="Top">
<Border BorderBrush="CornflowerBlue" BorderThickness="1" CornerRadius="5" Name="border">
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="White" Offset="0"/>
<GradientStop Color="#FFC0D3EA" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
<Grid Margin="2,0" Name="grid">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="20" MaxHeight="20" MinHeight="20" />
<RowDefinition MinHeight="20" />
</Grid.RowDefinitions>
<Label Content="00:00" FontWeight="Bold" Name="FromTime" Padding="5,0,0,0" VerticalContentAlignment="Center" />
<Label Content="01:30" Grid.Column="1" HorizontalContentAlignment="Right" Name="ToTime" Padding="0,0,5,0" VerticalContentAlignment="Center" />
<TextBlock Grid.ColumnSpan="2" Grid.Row="1" Name="MovieTitle" Padding="5,0" Text="item1" TextWrapping="Wrap" />
</Grid>
</Border>
And the user control class looks like this
Namespace Scheduler
Public Class ItemBox
Public Property Selected As Boolean
End Class
End Namespace
Now what i would like to do is, when i change the property Selected to True is the following: - set border borderbrush to black - set border borderthickness to 2 - set grid margin to 1
I would like to accomplish this by defining a "selected" style in the usercontrol that overrides the default styles when the selected property is set to True.
I know it has something to do with a style trigger and defining a custom attached property. But i can't seem to make it work the way i want to.