如何删除按钮之间的空间在stackpanel c# xaml
本文关键字:空间 stackpanel xaml 之间 按钮 何删除 删除 | 更新日期: 2023-09-27 18:17:33
在xaml布局中,按钮之间没有空格。然而,当我在模拟器或设备中测试它时,按钮之间有空格。我该如何解决这个问题?
<phone:PhoneApplicationPage
x:Class="KentKart.Pages.Page1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
FontFamily="{StaticResource PhoneFontFamilyNormal}"
FontSize="{StaticResource PhoneFontSizeNormal}"
Foreground="{StaticResource PhoneForegroundBrush}"
SupportedOrientations="Portrait" Orientation="Portrait"
mc:Ignorable="d"
shell:SystemTray.IsVisible="True">
<phone:PhoneApplicationPage.Resources>
<Style x:Key="SimpleButton" TargetType="Button">
<Setter Property="Margin" Value=",,,-13"/>
<Setter Property="Padding" Value="40,5,0,5"/>
<Setter Property="HorizontalContentAlignment" Value="Left"/>
<Setter Property="BorderThickness" Value="2"/>
<Setter Property="BorderBrush" Value="#0079c8"/>
<Setter Property="HorizontalAlignment" Value="Stretch"/>
<Setter Property="VerticalAlignment" Value="Stretch"/>
<Setter Property="Background" Value="White"/>
<Setter Property="Foreground" Value="#0079c8"/>
</Style>
</phone:PhoneApplicationPage.Resources>
<!--LayoutRoot is the root grid where all page content is placed-->
<Grid x:Name="LayoutRoot">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.Background>
<ImageBrush Stretch="Fill" ImageSource="/Assets/Images.xcassets/Background.imageset/bg@2x.png" AlignmentY="Top" AlignmentX="Center"/>
</Grid.Background>
<Grid Background="#0079c8" Height="92" VerticalAlignment="Top">
<TextBlock Width="auto" x:Name="selectedCityText" Foreground="White" Text="" RenderTransformOrigin="-0.243,0.771" FontSize="15" Margin="0,10,0,28" />
</Grid>
<!--TitlePanel contains the name of the application and page title-->
<StackPanel Grid.Row="0" Margin="12,17,0,28">
<Button Content="X" BorderThickness="0" HorizontalAlignment="Left" Margin="367,0,-12,0" VerticalAlignment="Top" Height="64" Width="113" Click="X_Button" RenderTransformOrigin="0.519,0.125"/>
</StackPanel>
<StackPanel VerticalAlignment="Top" Margin="0,92,0,0">
<Button Style="{StaticResource SimpleButton}" Content="deneme"/>
<Button Style="{StaticResource SimpleButton}" Content="deneme"/>
<Button Style="{StaticResource SimpleButton}" Content="deneme"/>
</StackPanel>
<!--ContentPanel - place additional content here-->
</Grid>
</phone:PhoneApplicationPage>
稍作调整后,解决方案是
<Setter Property="Margin" Value="0,-10,0,-10"/>
你有一个20像素的空白要删除。但是左和右的0
是至关重要的,当你把它们留空时,你可以看到默认值是负的(它们伸出帧外)。在设计器和设备上的呈现方式似乎有所不同。
所以这里可能有一个潜在的bug值得报告。