我想在Windows Phone 8中水平對齊的堆疊面板中安排兩個組件,一個向左,另一個向右。如何在Windows Phone 8的堆疊面板中將一個組件左對齊和右對齊
我需要左對齊的組件應該在頁面的左側,右對齊的組件應該在頁面的右側。這兩個組件之間應該有差距。
左對齊的組件是靜態的,右對齊的組件是動態的。 靜態組件我把寬度=自動和動態組件的剩餘空間。
以下是我的代碼。
<Border x:Name="DataBorder" Grid.Row="1" BorderBrush="Gray" CornerRadius="5,5,5,5" BorderThickness="2,2,2,2" Margin="10,30,10,10">
<StackPanel x:Name="settingsPanel" Orientation="Vertical">
<StackPanel x:Name="langPanel" Orientation="Horizontal">
<TextBlock x:Name="langTextBlock" Text="{Binding Path=LocalizedResources.DefaultLanguageText, Source={StaticResource LocalizedStrings}}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,0,0" Foreground="#FF501F6E" FontWeight="Bold" FontSize="25" Width="Auto"/>
<Button Content="English" Height="70" HorizontalAlignment="Right" Margin="5,1,0,0" Name="langbutton" VerticalAlignment="Center" MinWidth="160" Foreground="#FF501F6E" Click="language_Btn_clicked" BorderBrush="{x:Null}">
<Button.Background>
<ImageBrush Stretch="Fill" ImageSource="Images/blank_button_nav.png" />
</Button.Background>
</Button>
<!--<Image x:Name="arrow" Stretch="Fill" Margin="0,0,0,0" Source="Images/arrow.png" Height="20"/>-->
</StackPanel>
<StackPanel x:Name="pagePanel" Orientation="Horizontal">
<TextBlock x:Name="pageTextBlock" Text="{Binding Path=LocalizedResources.PerPageText, Source={StaticResource LocalizedStrings}}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,0,0" Foreground="#FF501F6E" FontWeight="Bold" FontSize="25" Width="Auto"/>
<Button Content="25" Height="70" HorizontalAlignment="Right" Margin="5,1,0,0" Name="pagebutton" VerticalAlignment="Center" MinWidth="160" Foreground="#FF501F6E" Click="page_Btn_clicked" BorderBrush="{x:Null}">
<Button.Background>
<ImageBrush Stretch="Fill" ImageSource="Images/blank_button_nav.png" />
</Button.Background>
</Button>
</StackPanel>
</StackPanel>
</Border>
但右對齊的組件即將到達左對齊的組件。