Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf 网格中的Windows Phone文本框对齐_Wpf_Silverlight_Windows Phone 7_Windows Phone 8_Windows Phone - Fatal编程技术网

Wpf 网格中的Windows Phone文本框对齐

Wpf 网格中的Windows Phone文本框对齐,wpf,silverlight,windows-phone-7,windows-phone-8,windows-phone,Wpf,Silverlight,Windows Phone 7,Windows Phone 8,Windows Phone,我在XAML中有以下代码 <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0"> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition/> <RowDefinition/> <RowDefinition/> <Ro

我在XAML中有以下代码

<Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
    <Grid.RowDefinitions>
        <RowDefinition/>
        <RowDefinition/>
        <RowDefinition/>
        <RowDefinition/>
        <RowDefinition/>
        <RowDefinition/>
        <RowDefinition/>
        <RowDefinition/>
        <RowDefinition/>
        <RowDefinition/>
       <RowDefinition/>
   </Grid.RowDefinitions>
   <Grid.ColumnDefinitions>
        <ColumnDefinition/>
        <ColumnDefinition/>
        <ColumnDefinition/>
        <ColumnDefinition/>
    </Grid.ColumnDefinitions>
    <TextBlock Grid.Row="2" Grid.Column="0" Grid.ColumnSpan="4" Grid.RowSpan="2" Foreground="Black" Text="Username"/>
    <TextBox Grid.Row="3" Grid.Column="0" Grid.ColumnSpan="4" Grid.RowSpan="1" Foreground="Black" Background="AliceBlue"/>
</Grid>

当我运行上面的代码时,textblock和textbox的对齐方式不一样。如何在不使用边距的情况下使文本块和文本框具有相同的左对齐方式

截屏

和一些its值,如果不更改其样式,通常无法覆盖。可能您必须更改默认的填充和边距(我在链接Padding=2处看到的内容)

为了确保我建议您在Blend中打开Page.xaml,请单击文本框,编辑模板->编辑副本(良好的屏幕截图)。与TextBlock相同(请按照上一链接中的问题进行操作)。当您设置相同的填充和边距时,您的元素应该对齐相同。

HorizontalAlignment=“Left”
TextAlignment=“Left”
在您的
TextBox
上显示您得到的图像,以帮助可视化您的问题。