Best way to convert wpf triggers to silverlight?
Posted
by Stewart Armbrecht
on Stack Overflow
See other posts from Stack Overflow
or by Stewart Armbrecht
Published on 2010-04-18T19:48:57Z
Indexed on
2010/04/18
19:53 UTC
Read the original article
Hit count: 544
I have developed several custom controls in a wpf application that use triggers. what is the fastest way to convert the code so that I have a single code base that works both in the wpf application and the silverlight applicaiton. Here is a sample of the code:
<Style x:Key="sButtonAction" TargetType="Button">
<!--<Setter Property="BitmapEffect" Value="{StaticResource BannerEffect}" />-->
<Setter Property="Height" Value="25" />
<Setter Property="Margin" Value="4" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="Button">
<Border x:Name="PART_Border" CornerRadius="10"
BorderThickness="{StaticResource sBorderThicknessStandard}"
BorderBrush="{StaticResource bColorBorder}"
Background="{StaticResource ButtonActionBackground}">
<TextBlock x:Name="PART_TextBlock" Margin="5,2,5,2" HorizontalAlignment="Center"
VerticalAlignment="Center" Foreground="White">
<ContentPresenter HorizontalAlignment="Center"
VerticalAlignment="Center" /></TextBlock>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="PART_TextBlock" Property="Foreground"
Value="#990000"></Setter>
</Trigger>
<Trigger Property="IsPressed" Value="True">
<Setter TargetName="PART_Border" Property="Background"
Value="{StaticResource ButtonActionBackgroundSelected}"></Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
© Stack Overflow or respective owner