Wpf 让网格控件填充父容器

Wpf 让网格控件填充父容器,wpf,xaml,Wpf,Xaml,我试图让这个网格控件填充到父容器的宽度。我看到了一些参考资料,水平对齐设置为“拉伸”(Stretch)应该可以工作,但对我来说它没有任何作用。网格的大小仅与我的最大文本块的宽度相同。我尝试过将宽度设置为“自动”,但也没有设置 <UniformGrid Rows="1" Columns="1" Height="75" Background="{StaticResource SteelBrush_Vert}" HorizontalAlignment="Stretch" VerticalAli

我试图让这个网格控件填充到父容器的宽度。我看到了一些参考资料,水平对齐设置为“拉伸”(Stretch)应该可以工作,但对我来说它没有任何作用。网格的大小仅与我的最大文本块的宽度相同。我尝试过将宽度设置为“自动”,但也没有设置

 <UniformGrid Rows="1" Columns="1" Height="75" Background="{StaticResource SteelBrush_Vert}" HorizontalAlignment="Stretch" VerticalAlignment="Bottom" Grid.Row="0">
        <Viewbox Width="auto">
            <Grid HorizontalAlignment="Stretch" Width="auto">
                <Grid.RowDefinitions>
                    <RowDefinition Height="7*"/>
                    <RowDefinition Height="18*"/>
                </Grid.RowDefinitions>
                <TextBlock x:Name="AppGreeting" Text="Good Morning, User" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10,5,0,4.6" FontWeight="Bold" Grid.RowSpan="2"/>
                <TextBlock x:Name="WindowName" Text="Home" HorizontalAlignment="Right" Margin="0,5,4.6,4.6" Grid.RowSpan="2"/>
            </Grid>

        </Viewbox>

    </UniformGrid>

在您的
视图框中使用
Stretch=“Fill”
属性

 <Viewbox Width="auto" Stretch="Fill">
            <Grid  HorizontalAlignment="Stretch">
                <Grid.RowDefinitions>
                    <RowDefinition Height="7*"/>
                    <RowDefinition Height="18*"/>
                </Grid.RowDefinitions>
                <TextBlock x:Name="AppGreeting" Text="Good Morning, User" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10,5,0,4.6" FontWeight="Bold" Grid.RowSpan="2"/>
                <TextBlock x:Name="WindowName" Text="Home" HorizontalAlignment="Right" Margin="0,5,4.6,4.6" Grid.RowSpan="2"/>
            </Grid>
 </Viewbox>

它是Viewbox,而不是Viewbox: