Bonjour à tous.
Je passe sûrement à côté de quelque chose au final assez simple, mais là j'avouerai ne plus trop voir par quel bout prendre la chose.
Je travaille en ce moment sur un programme devant afficher ou non des Grid et StackPanel suivant plusieurs critères.
N'arrivant pas à obtenir ce que je veux, j'ai tenté de faire un bout de XAML très simple pour voir si je ratais quelque chose.
L'exemple suivant est constitué d'une grille contenant 2 lignes et 2 colonnes. Dans chaque "case" est placé un stackPanel d'une couleur différente des autres. Jusqu'ici pas de problème. J'ai ensuite inclus dans chaque stackPanel une grid avec 2 lignes et 2 colonnes également, et dans une des cases d'une de ces grid, j'ai placé un autre stackpanel d'une couleur différente.
Problème : impossible de voir ce dernier stakpanel.
Je pense même que le soucis vient de la grid qui l'englobe, mais je n'en suis pas certain et je ne vois pas l'origine du problème.
Voici le code (j'ai mis un commentaire au dessus du stackpanel qui ne s'affiche pas)
Je travaille avec VS2012 avec le framework 4.5
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 <Window x:Class="TestGrid.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"> <Grid> <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> <StackPanel Grid.Column="0" Grid.Row="0" Background="Blue"> <Grid ShowGridLines="True"> <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> <!--Celui là ne s'affiche pas. Pourquoi?--> <StackPanel Grid.Row="1" Grid.Column="1" Background="YellowGreen" /> </Grid> </StackPanel> <StackPanel Grid.Column="1" Grid.Row="0" Background="Crimson"> <Grid ShowGridLines="True"> <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> </Grid> </StackPanel> <StackPanel Grid.Column="0" Grid.Row="1" Background="Green"> <Grid ShowGridLines="True"> <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> </Grid> </StackPanel> <StackPanel Grid.Column="1" Grid.Row="1" Background="Yellow"> <Grid ShowGridLines="True"> <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> </Grid> </StackPanel> </Grid> </Window>
Merci d'avance si vous avez une idée
Partager