.net Silverlight中的间距
我是Silverlight的新手,我在空间上有点困难。正如您在下面看到的,我有两行标签,每行位于水平堆叠面板中。当它们显示时,它们之间有一个很大的空间(大约一英寸)。我想不出如何缩小这个间距。身高特征似乎不起作用 提前谢谢.net Silverlight中的间距,.net,asp.net,silverlight-3.0,.net,Asp.net,Silverlight 3.0,我是Silverlight的新手,我在空间上有点困难。正如您在下面看到的,我有两行标签,每行位于水平堆叠面板中。当它们显示时,它们之间有一个很大的空间(大约一英寸)。我想不出如何缩小这个间距。身高特征似乎不起作用 提前谢谢 <UserControl x:Class="SilverlightApplication1.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmln
<UserControl x:Class="SilverlightApplication1.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d" d:DesignWidth="640" d:DesignHeight="480" Margin="10">
<StackPanel x:Name="LayoutRoot" Background="LightGray" Margin="10">
<StackPanel Orientation="Horizontal" Height="50" Width="500" Margin="10">
<TextBlock Height="15" Width="100" Margin="20"/>
<TextBlock Text="Heading" Height="15" Width="100" Margin="10"/>
<TextBlock Text="PDOF" Height="15" Width="100" Margin="15"/>
<TextBlock Text="PDOF" Height="15" Width="100" Margin="15"/>
</StackPanel>
<StackPanel Orientation="Horizontal" Height="50" Width="500" Margin="10">
<TextBlock Height="15" Width="100" Margin="20"/>
<TextBlock Text="(degrees)" Height="15" Width="60" Margin="10"/>
<TextBlock Text="locked" Height="15" Width="40" Margin="10"/>
<TextBlock Text="(degrees)" Height="15" Width="100" Margin="15"/>
<TextBlock Text="(O'Clock)" Height="15" Width="100" Margin="15"/>
</StackPanel>
</StackPanel>
</UserControl>
通过将边距指定为单个值
margin=“10”
可以在每个边(左、上、右、下)周围指定相等的边距10
您需要将边距分成左右两部分,然后说:
Margin="10,0,20,0"
通过这样做,只有左边和右边的空白,而不是顶部和底部。这需要应用于所有元素,因为边距是累积的
有关for页边距的详细信息如下:
<frameworkElement Margin="uniform"/>
- or -
<frameworkElement Margin="left+right,top+bottom"/>
- or -
<frameworkElement Margin="left,top,right,bottom"/>
指定没有垂直边距的水平边距,或
Margin="15,10"
指定水平边距,但指定较小的垂直边距
页面中的此图像说明了如何应用最后一个图像:
感谢ChrisF的回复。我决定换一种方式。我用帆布代替了StackPanel
Margin="15,10"