轉帖|其它|編輯:郝浩|2011-03-25 16:12:43.000|閱讀 640 次
概述:該例程使用Expression Blend創建一個簡單的圖形化Accordion幻燈效果。 主要利用ListBox的Selected和UnSelected事件,重新設計ItemContainerStyle樣式,沒有后臺代碼支持,僅僅XAML。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
該例程使用Expression Blend創建一個簡單的圖形化Accordion幻燈效果。 主要利用ListBox的Selected和UnSelected事件,重新設計ItemContainerStyle樣式,沒有后臺代碼支持,僅僅XAML。
源碼請看:
<UserControl.Resources>
<ItemsPanelTemplate x:Key="ItemsPanelTemplate1">
<StackPanel Orientation="Horizontal"/>
</ItemsPanelTemplate>
<Style x:Key="ListBoxItemStyle1" TargetType="ListBoxItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Grid x:Name="grid" Background="{TemplateBinding Background}" Width="55">
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="SelectionStates">
<VisualState x:Name="Unselected">
<Storyboard>
<DoubleAnimation Duration="0:0:0.3" To="55" Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="grid" >
<DoubleAnimation.EasingFunction>
<ElasticEase EasingMode="EaseIn" Springiness="6" Oscillations="0"/>
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
</VisualState>
<VisualState x:Name="SelectedUnfocused">
<Storyboard>
<DoubleAnimation Duration="0:0:0.3" To="500" Storyboard.TargetProperty="(FrameworkElement.Width)" Storyboard.TargetName="grid" >
<DoubleAnimation.EasingFunction>
<ElasticEase EasingMode="EaseIn" Springiness="6" Oscillations="0" />
</DoubleAnimation.EasingFunction>
</DoubleAnimation>
</Storyboard>
</VisualState>
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>
<ContentPresenter x:Name="contentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}"/>
<Rectangle x:Name="FocusVisualElement" RadiusY="1" RadiusX="1" Stroke="#FF6DBDD1" StrokeThickness="1" Visibility="Collapsed"/>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</UserControl.Resources>
<Grid x:Name="LayoutRoot" Background="#FFAFAFAF" Margin="10">
<ListBox SelectedIndex="0" ItemsPanel="{StaticResource ItemsPanelTemplate1}" ItemContainerStyle="{StaticResource ListBoxItemStyle1}" BorderBrush="{x:Null}" Background="{x:Null}" VerticalAlignment="Center" HorizontalAlignment="Center" Height="285" Margin="10">
<Image Source="B.JPG" Stretch="UniformToFill" Margin="0,0,1,0"/>
<Image Source="A.JPG" Stretch="UniformToFill" Margin="0,0,1,0"/>
<Image Source="C.JPG" Stretch="UniformToFill" Margin="0,0,1,0"/>
<Image Source="D.JPG" Stretch="UniformToFill" Margin="0,0,1,0"/>
<Image Source="E.JPG" Stretch="UniformToFill" Margin="0,0,1,0"/>
</ListBox>
</Grid>
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自:銀光中國網