Pourquoi StackPanel ne place-t-il pas le bloc de texte à gauche et le bouton à droite dans Silverlight?
OK, j'abandonne: que dois-je changer à ce StackPanel ci-dessous de sorte qu'il met l':
- texte à l'extrême gauche de la forme
- bouton sur l'extrême droite de la forme.
le texte d'alt http://tanguay.info/web/external/stackPanelLeftRight.png
<UserControl x:Class="TestData333.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
<Border CornerRadius="10" Background="Yellow" Padding="20">
<StackPanel VerticalAlignment="Top" HorizontalAlignment="Left">
<ScrollViewer Background="Beige"
Height="230"
Width="360">
<StackPanel>
<TextBlock x:Name="TheContent"
Foreground="Navy"
FontSize="14"
TextWrapping="Wrap"/>
</StackPanel>
</ScrollViewer>
<StackPanel Orientation="Horizontal">
<TextBlock x:Name="ProgressIndicator" Text="Ready..."
HorizontalAlignment="Left"/>
<Button Content="Load Data"
Width="100"
HorizontalAlignment="Right"
Click="Button_Load"
Margin="0 5 0 0"/>
</StackPanel>
</StackPanel>
</Border>
</Grid>
</UserControl>
RÉPONSE:
Téléchargé 3 Silverlight toolkit qui a DockPanel, installé, le Système référencé.De Windows.Commandes, puis XAML suivant:
<UserControl x:Class="TestData333.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:toolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
Width="400" Height="300">
<Grid x:Name="LayoutRoot" Background="White">
<Border CornerRadius="10" Background="Yellow" Padding="20">
<StackPanel VerticalAlignment="Top" HorizontalAlignment="Left">
<ScrollViewer Background="Beige"
Height="230"
Width="360">
<StackPanel>
<TextBlock x:Name="TheContent"
Foreground="Navy"
FontSize="14"
TextWrapping="Wrap"/>
</StackPanel>
</ScrollViewer>
<toolkit:DockPanel Margin="0 5 0 0">
<TextBlock toolkit:DockPanel.Dock="Left" x:Name="ProgressIndicator" Text="Ready..."
FontSize="12"
HorizontalAlignment="Left"/>
<Button toolkit:DockPanel.Dock="Right" Content="Load Data"
Width="100"
HorizontalAlignment="Right"
Click="Button_Load"/>
</toolkit:DockPanel>
</StackPanel>
</Border>
</Grid>
</UserControl>
le texte d'alt http://tanguay.info/web/external/silverlightDockPanel.png
source d'informationauteur Edward Tanguay
Vous devez vous connecter pour publier un commentaire.
vous pouvez utiliser dockpanel de la trousse ou de l'utilisation de la grille avec 2 colonnes. et le contenu de la deuxième colonne bien alignée
Voulez-vous dire que vous souhaitez que le bouton aligné à droite de la forme? Si oui, StackPanel ne le ferai pas. Il est fait à la "pile" soit horizontalement ou verticalement.
Je vous suggère d'essayer DockPanel:
Je pense que Matt approche, il est le meilleur. Deux alternatives sont cependant à utiliser une grille et aligner le contenu à gauche et à droite ou tout simplement le bouton d'une très grande marge.
De référence devrait être: