Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.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
C# 为什么不';我的列不是应该对齐吗?_C#_Wpf_Xaml - Fatal编程技术网

C# 为什么不';我的列不是应该对齐吗?

C# 为什么不';我的列不是应该对齐吗?,c#,wpf,xaml,C#,Wpf,Xaml,通过以下XAML,我得到了这个布局: 为什么我的文本框不与我创建的列对齐?为什么组合框会与列对齐?似乎文本框中的边距设置错误,导致它们的位置与网格的列不对齐 您的文本框的左边距为130。这是故意的吗?@rshepp你绝对是,100%,完全正确。我只是看了一下。请将其作为答案发布:) <GroupBox Header="Adres" Grid.Row="1" Grid.RowSpan="5"> <Grid ShowGridLines="True">

通过以下XAML,我得到了这个布局:



为什么我的文本框不与我创建的列对齐?为什么组合框会与列对齐?

似乎文本框中的边距设置错误,导致它们的位置与网格的列不对齐

您的文本框的左边距为130。这是故意的吗?@rshepp你绝对是,100%,完全正确。我只是看了一下。请将其作为答案发布:)
<GroupBox Header="Adres" Grid.Row="1" Grid.RowSpan="5">
    <Grid ShowGridLines="True">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="150"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Label HorizontalAlignment="Left" Content="Straat:"/>
        <TextBox Margin="130,0,0,0" Text="{Binding Address.Street}" Grid.Column="1" Grid.ColumnSpan="3" />

        <Label HorizontalAlignment="Left" Grid.Row="1" Content="Nr:"/>
        <TextBox Margin="130,0,0,0" Text="{Binding Address.Number}" Grid.Row="1" Grid.Column="1" Grid.ColumnSpan="2" />
        <Label HorizontalAlignment="Left" Grid.Row="1" Content="Ext:" Grid.Column="3"/>
        <TextBox Margin="130,0,0,0" Text="{Binding Address.NumberExtension}" Grid.Row="1" Grid.Column="3" />

        <Label HorizontalAlignment="Left" Content="Gemeente:" Grid.Row="2"/>
        <ComboBox ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListView}}, Path=DataContext.Towns}" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Stretch">
        </ComboBox>
        <ComboBox ItemsSource="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type ListView}}, Path=DataContext.Towns}" Grid.Row="2" Grid.ColumnSpan="2" Grid.Column="2">
        </ComboBox>

        <Label Width="125" HorizontalAlignment="Left" Content="Land:" Grid.Row="3"/>
        <TextBox Margin="130,0,0,0" Text="{Binding Address.Country}" Grid.Column="1" Grid.ColumnSpan="3" Grid.Row="3" />
    </Grid>
</GroupBox>