Bonjour tout le monde
j'ai un petit souci de scrollview je n'arrive pas à l’intégrer à mes tabitems. J'aurais voulu scroller aussi bien en vertical qu'en horizontal si besoin est. Je ne sais pas s'il faut le mettre dans mon usercontrol ou dans ma ressouces Mainwindows suivant la résolution de l'ecran.
Pouvez-vous me donner un petit coup de main.
Xaml MainWindows :
Mon fichier Ressouces MainWindows :
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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125 <Window x:Class="Apeiron.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:vm="clr-namespace:Apeiron.ViewModel" xmlns:view="clr-namespace:Apeiron.View" FontSize="13" FontFamily="Verdana" Title="{Binding Path=DisplayName}" SizeToContent="WidthAndHeight" WindowStartupLocation="CenterScreen" WindowState="Maximized" > <DockPanel> <DockPanel DockPanel.Dock="Top" KeyboardNavigation.TabNavigation="None"> <Menu KeyboardNavigation.TabNavigation="Cycle"> <MenuItem Header="_Fichier"> <MenuItem Header="_Ouvrir" Command="{Binding Path=OpenCommand}" /> <MenuItem Header="_Recent" Command="{Binding Path=CloseCommand}" /> <Separator /> <MenuItem Header="_Enregistrer" Command="{Binding Path=CloseCommand}" /> <MenuItem Header="_Enregistrer Sous" Command="{Binding Path=CloseCommand}" /> <Separator /> <MenuItem Header="_Fermer Projet" Command="{Binding Path=CloseCommand}" /> <MenuItem Header="_Quitter" Command="{Binding Path=CloseCommand}" /> </MenuItem> <MenuItem Header="_Help" /> </Menu> </DockPanel> <Grid Margin="4" Width="{Binding ActualWidth, RelativeSource = {RelativeSource AncestorType = {x:Type Window}}}" Height="{Binding ActualHeight, RelativeSource ={RelativeSource AncestorType = {x:Type Window}}}"> <Grid.ColumnDefinitions> <ColumnDefinition Width="170" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Border Grid.Column="0" Width="170"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="170"></ColumnDefinition> </Grid.ColumnDefinitions> <ListBox ScrollViewer.VerticalScrollBarVisibility="Auto"> <ListBox.Resources> <Style TargetType="{x:Type Expander}"> <Setter Property="IsExpanded" Value="{Binding Path=IsSelected, RelativeSource={RelativeSource AncestorType={x:Type ListBoxItem}}}"/> </Style> </ListBox.Resources> <ListBox.Template> <ControlTemplate TargetType="{x:Type ListBox}"> <ItemsPresenter/> </ControlTemplate> </ListBox.Template> <ListBox.ItemContainerStyle> <Style TargetType="{x:Type ListBoxItem}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ListBoxItem}"> <ContentPresenter Content="{TemplateBinding Content}"/> </ControlTemplate> </Setter.Value> </Setter> </Style> </ListBox.ItemContainerStyle> <Expander Background="#FF5D3397" Margin="0,0,0,0"> <Expander.Header> <BulletDecorator> <BulletDecorator.Bullet> <StackPanel Orientation="Horizontal"> <Image Source="/Apeiron;component/Utils/Images/Accueilbis.png" Width="32" Height="32" HorizontalAlignment="Left" VerticalAlignment="Top" RenderOptions.BitmapScalingMode="HighQuality"/> <Label Content="Accueil" Foreground="white" Height="32" HorizontalAlignment="Left" VerticalContentAlignment="Center"/> </StackPanel> </BulletDecorator.Bullet> </BulletDecorator> </Expander.Header> <HeaderedContentControl Content="{Binding Path=CommandProjet}" ContentTemplate="{StaticResource CommandsProjet}" /> </Expander> </ListBox> </Grid> <!-- <HeaderedContentControl Content="{Binding Path=Commands}" ContentTemplate="{StaticResource CommandsTemplate}" Header="Control Panel" /> --> </Border> <Border Grid.Column="1"> <HeaderedContentControl Content="{Binding Path=Workspaces}" ContentTemplate="{StaticResource WorkspacesTemplate}" HorizontalAlignment="Left" BorderThickness="0" BorderBrush="{x:Null}" VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch" Margin="0" ></HeaderedContentControl> </Border> </Grid> </DockPanel> </Window>
Un de mes Usercontrol :
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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147 <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:vm="clr-namespace:Apeiron.ViewModel" xmlns:vw="clr-namespace:Apeiron.View" > <DataTemplate DataType="{x:Type vm:ProjetViewModel}"> <vw:Projet /> </DataTemplate> <Style x:Key="MainHCCStyle" TargetType="{x:Type HeaderedContentControl}"> <Setter Property="HeaderTemplate"> <Setter.Value> <DataTemplate> <Border Background="{StaticResource Brush_HeaderBackground}" BorderBrush="LightGray" BorderThickness="1" CornerRadius="5" Margin="4" Padding="4" SnapsToDevicePixels="True" > <TextBlock FontSize="10" FontWeight="Bold" Foreground="White" HorizontalAlignment="Center" Text="{TemplateBinding Content}" /> </Border> </DataTemplate> </Setter.Value> </Setter> <Setter Property="IsTabStop" Value="False" /> <Setter Property="Template"> <Setter.Value> <!-- This template ensures that content of a HeaderedContentControl fills the available vertical space. --> <ControlTemplate TargetType="{x:Type HeaderedContentControl}"> <DockPanel> <ContentPresenter DockPanel.Dock="Top" ContentSource="Header" ContentTemplate="{TemplateBinding HeaderTemplate}" /> <ContentPresenter ContentSource="Content" ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Auto" ContentTemplate="{TemplateBinding ContentTemplate}" > </ContentPresenter> </DockPanel> </ControlTemplate> </Setter.Value> </Setter> </Style> <Style x:Key="MainBorderStyle" TargetType="{x:Type Border}"> <Setter Property="Background" Value="WhiteSmoke" /> <Setter Property="BorderBrush" Value="LightGray" /> <Setter Property="BorderThickness" Value="1" /> <Setter Property="CornerRadius" Value="5" /> <Setter Property="SnapsToDevicePixels" Value="True" /> </Style> <DataTemplate x:Key="CommandsProjet"> <ItemsControl IsTabStop="False" ItemsSource="{Binding}" Margin="0"> <ItemsControl.ItemTemplate> <DataTemplate> <Button Command="{Binding Path=CommandProjet}" BorderBrush="{x:Null}" Foreground="white" HorizontalContentAlignment="Left" Background="{x:Null}"> <StackPanel Orientation="Horizontal"> <Image Source="/Apeiron;component/Utils/Images/Fleche.png" Width="24" Height="20" HorizontalAlignment="Left" VerticalAlignment="Top" /> <Label Content="{Binding Path=DisplayName}" Height="24" Foreground="white" HorizontalAlignment="Left" VerticalContentAlignment="Center" FontSize="10"/> </StackPanel> </Button> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> </DataTemplate> <DataTemplate x:Key="ClosableTabItemTemplate"> <DockPanel Width="110"> <Button Command="{Binding Path=CloseCommand}" Cursor="Hand" DockPanel.Dock="Right" Focusable="False" VerticalContentAlignment="Bottom" Background="White" BorderThickness="0" > <Button.Template> <ControlTemplate> <Image Width="12" Height="12" Source="/Apeiron;component/Utils/Images/Close.png" RenderOptions.BitmapScalingMode="HighQuality" Stretch="Uniform"></Image> </ControlTemplate> </Button.Template> </Button> <ContentPresenter Content="{Binding Path=DisplayName}" TextBlock.FontSize="10" TextBlock.FontWeight="Bold" VerticalAlignment="Center" /> </DockPanel> </DataTemplate> <DataTemplate x:Key="WorkspacesTemplate"> <TabControl ScrollViewer.CanContentScroll="True" ScrollViewer.VerticalScrollBarVisibility="Auto" IsSynchronizedWithCurrentItem="True" BorderThickness="0" ItemsSource="{Binding}" ItemTemplate="{StaticResource ClosableTabItemTemplate}" /> </DataTemplate> </ResourceDictionary>
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
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229 <UserControl x:Class="Apeiron.View.Projet" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:Apeiron.View" mc:Ignorable="d" MaxHeight="{Binding Source={x:Static SystemParameters.PrimaryScreenHeight}, Converter={local:RatioConverter}, ConverterParameter='0.9' }" > <Grid> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="300"/> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Grid Grid.Column="1"> <GroupBox Grid.Row="0" Margin="3" Header="Perspective du Projet" VerticalAlignment="Top" Height="226.8"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="auto"/> <ColumnDefinition Width="auto" /> </Grid.ColumnDefinitions> <Button Grid.Column="0" Width="170" ToolTip="Cliquer ici pour charger une image"> <TextBlock> <Image /> </TextBlock> </Button> </Grid> </GroupBox> </Grid> <Grid Grid.Column="0"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <StackPanel> <GroupBox Grid.Row="0" Margin="3" Header="Partenaires du Projet" Width="auto"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="auto"/> <ColumnDefinition Width="auto" /> </Grid.ColumnDefinitions> <StackPanel Grid.Column="0"> <CheckBox Style="{DynamicResource Checkbox}" x:Name="ButtonMO" Content="Maître d'Ouvrage" IsChecked="True" FontSize="10" Margin="3" VerticalContentAlignment="Center" /> <CheckBox Style="{DynamicResource Checkbox}" x:Name="ButtonMOE" Content="Maître d'Oeuvre" FontSize="10" Margin="3" VerticalContentAlignment="Center"/> <CheckBox Style="{DynamicResource Checkbox}" x:Name="ButtonMOED" Content="Maître d'Ouvrage Délégué" FontSize="10" Margin="3" VerticalContentAlignment="Center"/> </StackPanel> <StackPanel Grid.Column="1"> <CheckBox Style="{DynamicResource Checkbox}" x:Name="ButtonBETF" Content="Bureau d'étude fluide" FontSize="10" Margin="3" VerticalContentAlignment="Center"/> <CheckBox Style="{DynamicResource Checkbox}" x:Name="ButtonBC" Content="Bureau de Contrôle" FontSize="10" Margin="3" VerticalContentAlignment="Center"/> </StackPanel> </Grid> </GroupBox> <GroupBox Grid.Row="1" Header="Description du Projet" Grid.Column="0" Margin="3" Background="Transparent" Width="auto" Height="auto" VerticalAlignment="Top"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="130"/> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Label Grid.Row ="0" Content="Référence Projet" VerticalAlignment="Center" VerticalContentAlignment="Center"/> <Label Grid.Row ="1" Content="Nom du Projet / Site" VerticalAlignment="Center" VerticalContentAlignment="Center"/> <Label Grid.Row ="2" Content="Désignation du Projet" VerticalAlignment="Center" VerticalContentAlignment="Center"/> <Label Grid.Row ="3" Content="Adresse du Projet" VerticalAlignment="Center" VerticalContentAlignment="Center"/> <Label Grid.Row ="4" Content="Lot" VerticalAlignment="Center" VerticalContentAlignment="Center"/> <TextBox Margin="2" Grid.Row ="0" Grid.Column="1" VerticalAlignment="Center" Height="21"/> <TextBox Margin="2" Grid.Row ="1" Grid.Column="1" VerticalAlignment="Center" Height="21"/> <TextBox Margin="2" Grid.Row ="2" Grid.Column="1" VerticalAlignment="Center" Height="21"/> <TextBox Margin="2" Grid.Row ="3" Grid.Column="1" VerticalAlignment="Center" Height="21"/> <TextBox Margin="2" Grid.Row ="4" Grid.Column="1" VerticalAlignment="Center" Height="21"/> <TextBox Margin="2" Grid.Row ="5" Grid.Column="1" VerticalAlignment="Center" Height="21"/> </Grid> </GroupBox> <GroupBox Style="{StaticResource ShowMO}" Grid.Row="2" Header="Maître d'Ouvrage" Margin="3" Background="Transparent" Width="auto" Height="auto" VerticalAlignment="Top"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="130"/> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Label Grid.Row ="0" Content="Désignation" VerticalAlignment="Center" VerticalContentAlignment="Center"/> <Label Grid.Row ="1" Content="Adresse" VerticalAlignment="Center" VerticalContentAlignment="Center"/> <Label Grid.Row ="2" Content="Téléphone" VerticalAlignment="Center" VerticalContentAlignment="Center"/> <Label Grid.Row ="3" Content="Mail" VerticalAlignment="Center" VerticalContentAlignment="Center"/> <TextBox Margin="2" Grid.Row ="0" Grid.Column="1" VerticalAlignment="Center" Height="21"/> <TextBox Margin="2" Grid.Row ="1" Grid.Column="1" VerticalAlignment="Center" Height="21"/> <TextBox Margin="2" Grid.Row ="2" Grid.Column="1" VerticalAlignment="Center" Height="21"/> <TextBox Margin="2" Grid.Row ="3" Grid.Column="1" VerticalAlignment="Center" Height="21"/> <TextBox Margin="2" Grid.Row ="4" Grid.Column="1" VerticalAlignment="Center" Height="21"/> </Grid> </GroupBox> <GroupBox Style="{StaticResource ShowMOE}" Grid.Row="2" Header="Maître d'Oeuvre" Margin="3" Background="Transparent" Width="auto" Height="auto" VerticalAlignment="Top"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="130"/> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Label Grid.Row ="0" Content="Désignation" VerticalAlignment="Center" VerticalContentAlignment="Center"/> <Label Grid.Row ="1" Content="Adresse" VerticalAlignment="Center" VerticalContentAlignment="Center"/> <Label Grid.Row ="2" Content="Téléphone" VerticalAlignment="Center" VerticalContentAlignment="Center"/> <Label Grid.Row ="3" Content="Mail" VerticalAlignment="Center" VerticalContentAlignment="Center"/> <TextBox Margin="2" Grid.Row ="0" Grid.Column="1" VerticalAlignment="Center" Height="21"/> <TextBox Margin="2" Grid.Row ="1" Grid.Column="1" VerticalAlignment="Center" Height="21"/> <TextBox Margin="2" Grid.Row ="2" Grid.Column="1" VerticalAlignment="Center" Height="21"/> <TextBox Margin="2" Grid.Row ="3" Grid.Column="1" VerticalAlignment="Center" Height="21"/> <TextBox Margin="2" Grid.Row ="4" Grid.Column="1" VerticalAlignment="Center" Height="21"/> </Grid> </GroupBox> <GroupBox Style="{StaticResource ShowBETF}" Grid.Row="2" Header="Bureau d'étude fluides" Margin="3" Background="Transparent" Width="auto" Height="auto" VerticalAlignment="Top"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="130"/> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Label Grid.Row ="0" Content="Désignation" VerticalAlignment="Center" VerticalContentAlignment="Center"/> <Label Grid.Row ="1" Content="Adresse" VerticalAlignment="Center" VerticalContentAlignment="Center"/> <Label Grid.Row ="2" Content="Téléphone" VerticalAlignment="Center" VerticalContentAlignment="Center"/> <Label Grid.Row ="3" Content="Mail" VerticalAlignment="Center" VerticalContentAlignment="Center"/> <TextBox Margin="2" Grid.Row ="0" Grid.Column="1" VerticalAlignment="Center" Height="21"/> <TextBox Margin="2" Grid.Row ="1" Grid.Column="1" VerticalAlignment="Center" Height="21"/> <TextBox Margin="2" Grid.Row ="2" Grid.Column="1" VerticalAlignment="Center" Height="21"/> <TextBox Margin="2" Grid.Row ="3" Grid.Column="1" VerticalAlignment="Center" Height="21"/> <TextBox Margin="2" Grid.Row ="4" Grid.Column="1" VerticalAlignment="Center" Height="21"/> </Grid> </GroupBox> <GroupBox Style="{StaticResource ShowBC}" Grid.Row="2" Header="Bureau d'étude fluides" Margin="3" Background="Transparent" Width="auto" Height="auto" VerticalAlignment="Top"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="130"/> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Label Grid.Row ="0" Content="Désignation" VerticalAlignment="Center" VerticalContentAlignment="Center"/> <Label Grid.Row ="1" Content="Adresse" VerticalAlignment="Center" VerticalContentAlignment="Center"/> <Label Grid.Row ="2" Content="Téléphone" VerticalAlignment="Center" VerticalContentAlignment="Center"/> <Label Grid.Row ="3" Content="Mail" VerticalAlignment="Center" VerticalContentAlignment="Center"/> <TextBox Margin="2" Grid.Row ="0" Grid.Column="1" VerticalAlignment="Center" Height="21"/> <TextBox Margin="2" Grid.Row ="1" Grid.Column="1" VerticalAlignment="Center" Height="21"/> <TextBox Margin="2" Grid.Row ="2" Grid.Column="1" VerticalAlignment="Center" Height="21"/> <TextBox Margin="2" Grid.Row ="3" Grid.Column="1" VerticalAlignment="Center" Height="21"/> <TextBox Margin="2" Grid.Row ="4" Grid.Column="1" VerticalAlignment="Center" Height="21"/> </Grid> </GroupBox> </StackPanel> </Grid> </Grid> </Grid> </UserControl>
Partager