Set a border around a StackPanel.

后端 未结 3 1956
生来不讨喜
生来不讨喜 2021-01-01 08:29

Here\'s my XAML code:



        
相关标签:
3条回答
  • 2021-01-01 08:55

    You set DockPanel.Dock="Top" to the StackPanel, but the StackPanel is not a child of the DockPanel... the Border is. Your docking property is being ignored.

    If you move DockPanel.Dock="Top" to the Border instead, both of your problems will be fixed :)

    0 讨论(0)
  • 2021-01-01 08:56

    May be it will helpful:

    <Border BorderBrush="Black" BorderThickness="1" HorizontalAlignment="Left" Height="160" Margin="10,55,0,0" VerticalAlignment="Top" Width="492"/>
    
    0 讨论(0)
  • 2021-01-01 09:09

    What about this one :

    <DockPanel Margin="8">
        <Border CornerRadius="6" BorderBrush="Gray" Background="LightGray" BorderThickness="2" DockPanel.Dock="Top">
            <StackPanel Orientation="Horizontal">
                <TextBlock FontSize="14" Padding="0 0 8 0" HorizontalAlignment="Center" VerticalAlignment="Center">Search:</TextBlock>
                <TextBox x:Name="txtSearchTerm" HorizontalAlignment="Center" VerticalAlignment="Center" />
                <Image Source="lock.png" Width="32" Height="32" HorizontalAlignment="Center" VerticalAlignment="Center" />            
            </StackPanel>
        </Border>
        <StackPanel Orientation="Horizontal" DockPanel.Dock="Bottom" Height="25" />
    </DockPanel>
    
    0 讨论(0)
提交回复
热议问题