12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- <UserControl x:Class="WpfDemo.DescriptionControl" Style="{DynamicResource Style1}"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:local="clr-namespace:WpfDemo">
- <UserControl.Resources>
- <Style x:Key="Style1" TargetType="UserControl">
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="local:DescriptionControl">
- <StackPanel MaxWidth="600">
- <ToggleButton x:Name="button" IsChecked="True" Width="90" Height="22" HorizontalAlignment="Right" Background="White" BorderBrush="LightGray">
- <StackPanel Orientation="Horizontal">
- <Path Data="M0,0.5 L7,0.5 M0,2.5 L7,2.5 M0,4.5 L7,4.5" Stroke="Black" VerticalAlignment="Center"/>
- <TextBlock Text="{TemplateBinding Header}" Margin="6,0,0,0"/>
- </StackPanel>
- </ToggleButton>
- <Grid x:Name="callout" Visibility="Collapsed" Margin="0,0,-3,0">
- <Path Data="M0,16 L16,0 L32,16 Z" Width="32" Height="12" Fill="WhiteSmoke" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,0,20,0" Panel.ZIndex="1"/>
- <Path Data="M0,16 L16,0 L32,16" Width="32" Height="12" Stroke="LightGray" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,0,20,0" Panel.ZIndex="2"/>
- <Border Background="WhiteSmoke" BorderThickness="1" BorderBrush="LightGray" Margin="0,11,0,0">
- <Border.Effect>
- <DropShadowEffect Color="LightGray" ShadowDepth="1" Direction="270" />
- </Border.Effect>
- <StackPanel>
- <TextBlock Text="{TemplateBinding Description}" Padding="10" TextWrapping="Wrap"/>
- <TextBlock x:Name="hyperlink" Padding="10">
- <Hyperlink Click="Hyperlink_Click">
- <TextBlock Text="{TemplateBinding LinkText}"/>
- </Hyperlink>
- </TextBlock>
- </StackPanel>
- </Border>
- </Grid>
- </StackPanel>
- <ControlTemplate.Triggers>
- <Trigger SourceName="button" Property="IsChecked" Value="True">
- <Setter TargetName="callout" Property="Visibility" Value="Visible"/>
- <Trigger.EnterActions>
- <BeginStoryboard>
- <Storyboard>
- <DoubleAnimation From="0" To="1" Duration="0:0:0.3" Storyboard.TargetName="callout" Storyboard.TargetProperty="Opacity"/>
- </Storyboard>
- </BeginStoryboard>
- </Trigger.EnterActions>
- </Trigger>
- <Trigger Property="Description" Value="">
- <Setter TargetName="callout" Property="Visibility" Value="Collapsed"/>
- </Trigger>
- <Trigger Property="Link" Value="">
- <Setter TargetName="hyperlink" Property="Visibility" Value="Collapsed"/>
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- </UserControl.Resources>
- </UserControl>
|