Bonjour,
Je découvre les joies des templates et des styles. Néanmoins je suis tombé sur un os, qui semble peut être idiot à première vu mais je n'ai pas trouvé de solution actuellement.
J'ai créé un template pour une window :
J'appliques ce template à toutes mes fenêtre de mon application. Mais le hic, c'est que tout ce que je rajoute à la fenêtre en plus de ce template n'apparait pas ...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <ControlTemplate x:Key="Template_Forms" TargetType="{x:Type Window}"> <Grid Name="Main_Grid" Background="Transparent"> <Grid.RowDefinitions> <RowDefinition Height="24" /> <RowDefinition Height="24" /> <RowDefinition Height="370*" /> <RowDefinition Height="24*" /> </Grid.RowDefinitions> <Grid> <Grid.Background> <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> <GradientStop Color="Gray" Offset="1.1"></GradientStop> <GradientStop Color="Gray" Offset="0.5"></GradientStop> <GradientStop Color="White" Offset="0.0"></GradientStop> </LinearGradientBrush> </Grid.Background> <StackPanel Name="Upper_SP" Background="Transparent" Orientation="Horizontal" HorizontalAlignment="Right" > <e:ControlBox Name="Reduce_Btn" Function_Type="Reduce" Source="/Caldeira;component/Resources/Reduce.png"></e:ControlBox> <e:ControlBox Name="Level_Btn" Function_Type="Level" Source="/Caldeira;component/Resources/stop-icon.png"></e:ControlBox> <e:ControlBox Name="Quit_Btn" Function_Type="Quit" Source="/Caldeira;component/Resources/remove-icon.png"></e:ControlBox> </StackPanel> </Grid> <StackPanel Grid.Column="0" Grid.Row="1" Name="ToolBar_SP" Background="Gray" Orientation="Horizontal" Margin="0,0,0,0"> </StackPanel> <Grid Name="Content_Grid" Grid.Column="0" Grid.Row="2" Background="Gray"> </Grid> <StackPanel Grid.Column="0" Grid.Row="3" Name="StackPanel2"> <StackPanel.Background> <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> <GradientStop Color="Gray" Offset="0.0"></GradientStop> <GradientStop Color="Gray" Offset="0.5"></GradientStop> <GradientStop Color="White" Offset="1.1"></GradientStop> </LinearGradientBrush> </StackPanel.Background> </StackPanel> </Grid> </ControlTemplate>
Exemple sur une de mes fenêtre :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 <Window x:Class="Profiles_Manager" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Profiles_Manager" Name="Profile_Manager_Win" Height="384" Width="453" WindowStyle="None" AllowsTransparency="true" Template="{StaticResource Template_Forms}"> <TreeView Grid.Row="2" Grid.Column="0" Margin="0,0,1,0" Name="TreeView1" Background="Transparent"> <TreeViewItem IsExpanded="true"> <TreeViewItem.Header> <StackPanel Orientation="Horizontal" Width="420"> <StackPanel.Background> <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1"> <GradientStop Color="Gray" Offset="1.1"></GradientStop> <GradientStop Color="LightGray" Offset="0.5"></GradientStop> <GradientStop Color="Gray" Offset="0.0"></GradientStop> </LinearGradientBrush> </StackPanel.Background> <Image Source="/Caldeira;component/Resources/Project.png" Height="20"></Image> <TextBlock Margin="5,0,0,0" Text="YASHAT-1B" VerticalAlignment="Center"></TextBlock> </StackPanel> </TreeViewItem.Header> </TreeViewItem> </TreeView> </Window>
Le Treeview ajouté sur la Window n'apparait pas ... La solution est peut être bête mais je ne trouve pas la solution ^^
Merci d'avance pour vos réponses.
Partager