Taille de la window en fonction du contenu.
Bonjour,
Est-il possible, à partir d'une window avec un StackPanel comme conteneur principal, d'ajuster la propriété Height en fonction du contenu du StackPanel?
Je m'explique. Prenons le code suivant :
Code:
1 2 3 4 5 6 7 8
| <Window x:Class="Projet.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Login" Width="300" HorizontalAlignment="Center" WindowStyle="None" AllowsTransparency="True">
<StackPanel Background="Green" Name="spPrincipal">
<!-- du contenu -->
</StackPanel>
</Window> |
Le StackPanel spPrincipal peut contenir divers controls et j'aimerais que la taille du Window s'adapte en fonction. Si le StackPanel contient un seul bouton ayant Height="20", alors la fenêtre doit faire 20 de haut (enfin pas exactement vu accaparement la propriété height d'une window dépend de la barre de titre), si on ajoute des objet, leur taille s'ajoute.
J'ai essayé de binder la taille de la Window à celle du StackPanel, mais je me retrouve avec un truc 10fois trop grand :roll:
Vous savez comment faire?