1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102
| <Window x:Class="TestList.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow"
WindowStyle="None"
ResizeMode="NoResize"
AllowsTransparency="True"
Background="Transparent"
Width="500" Top="0" Loaded="Window_Loaded">
<Window.Resources>
<!-- Template de la ListBox THEMES -->
<DataTemplate x:Key="ThemeTemplate">
<StackPanel HorizontalAlignment="Center" Margin="10">
<Image Source="{Binding Path=UriLogo}" Width="64" Height="64">
<Image.ToolTip>
<TextBlock Text="{Binding Path=Description}"/>
</Image.ToolTip>
</Image>
<TextBlock TextAlignment="Center" Text="{Binding Path=Nom}"/>
</StackPanel>
</DataTemplate>
<!-- Template de la ListBox APPLICATION -->
<DataTemplate x:Key="ApplicationListItemStyle">
<StackPanel Orientation="Horizontal" Margin="5" >
<StackPanel.ToolTip>
<TextBlock Text="{Binding Path=Description}" />
</StackPanel.ToolTip>
<Image Source="{Binding Path=LogoUri}" Margin="0 0 10 0" Width="32" Height="32"/>
<TextBlock VerticalAlignment="Center" Text="{Binding Path=Nom}"/>
</StackPanel>
</DataTemplate>
<ControlTemplate x:Key="ThemeListTemplate" TargetType="{x:Type ListBoxItem}">
<Border x:Name="Bd" SnapsToDevicePixels="true" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}" RenderTransformOrigin="0.5,0.5">
<Border.RenderTransform>
<TransformGroup>
<ScaleTransform/>
</TransformGroup>
</Border.RenderTransform>
<ContentPresenter x:Name="contentPresenter" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</Border>
<ControlTemplate.Triggers>
<EventTrigger RoutedEvent="MouseEnter">
<BeginStoryboard Storyboard="{StaticResource RollOverAnim}"/>
</EventTrigger>
<EventTrigger RoutedEvent="MouseLeave">
<BeginStoryboard Storyboard="{StaticResource RollOutAnim}"/>
</EventTrigger>
</ControlTemplate.Triggers>
</ControlTemplate>
<Style x:Key="ThemeListStyle" TargetType="{x:Type ListBoxItem}">
<Setter Property="Template" Value="{StaticResource ThemeListTemplate}"/>
</Style>
<Storyboard x:Key="RollOverAnim">
<DoubleAnimation Duration="0:0:0.1" AutoReverse="False" Storyboard.TargetName="Bd" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" To="1.5" />
<DoubleAnimation Duration="0:0:0.1" AutoReverse="False" Storyboard.TargetName="Bd" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" To="1.5" />
</Storyboard>
<Storyboard x:Key="RollOutAnim">
<DoubleAnimation Duration="0:0:0.1" AutoReverse="False" Storyboard.TargetName="Bd" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleX)" To="1" />
<DoubleAnimation Duration="0:0:0.1" AutoReverse="False" Storyboard.TargetName="Bd" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[0].(ScaleTransform.ScaleY)" To="1" />
</Storyboard>
</Window.Resources>
<DockPanel Background="Transparent"
Name="ParentElement"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<ListBox x:Name="ThemeList"
Background="Transparent"
BorderBrush="Transparent"
DockPanel.Dock="Top"
ItemsSource="{Binding}"
ItemTemplate="{StaticResource ThemeTemplate}"
Cursor="Hand"
ItemContainerStyle="{StaticResource ThemeListStyle}"
SelectionChanged="ThemeList_SelectionChanged">
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" Margin="10"/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
<Canvas>
<ListBox x:Name="ApplicationList" ScrollViewer.VerticalScrollBarVisibility="Disabled"
ItemsSource="{Binding ElementName=ThemeList, Path=SelectedItem.Applications}"
ItemTemplate="{StaticResource ApplicationListItemStyle}"
SelectionChanged="ApplicationList_SelectionChanged">
</ListBox>
</Canvas>
</DockPanel>
</Window> |
Partager