如何水平对齐控件?

时间:2019-11-17 16:40:13

标签: c# wpf xaml alignment

我试图通过将标签和组合框保持在左侧,同时将两个按钮保持在右侧,在控件下方水平对齐。我已经尝试过使用StackPanel的不同方法,但是没有任何东西可以提供所需的输出。欣赏你们是否可以指出我在这里做错了吗?

  

当前布局

enter image description here

  

XAML来源

        <StackPanel HorizontalAlignment="Stretch" VerticalAlignment="Center" Orientation="Vertical" Margin="0,0,0,2" >

            <StackPanel Orientation="Horizontal" VerticalAlignment="Center">

                <StackPanel HorizontalAlignment="Left" Orientation="Horizontal" VerticalAlignment="Center">
                    <Label Content="Age Bucket" HorizontalAlignment="Left" VerticalAlignment="Center" />

                    <ComboBox HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,0,0" Width="100" 
              SelectedValue="{Binding SelectedAgeBucket}"
              DisplayMemberPath="DisplayMember" SelectedValuePath="ValueMember"
              ItemsSource="{Binding AgeBuckets}" IsSynchronizedWithCurrentItem="True"/>                        
                </StackPanel>

                <StackPanel HorizontalAlignment="Right" VerticalAlignment="Center" Orientation="Horizontal" Margin="0,0,0,2">
                    <Button   Click="Button_Click_1" Content="Export" HorizontalAlignment="Right" />
                    <Button  HorizontalAlignment="Right" VerticalAlignment="Center"  Click="Button_Click_2" Content="Print" Margin="5,0" />
                </StackPanel>

            </StackPanel>

            <telerik:RadDataPager x:Name="radDataPager" Source="{Binding Items, ElementName=grdDetails}" PageSize="100" />

        </StackPanel>

0 个答案:

没有答案