Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.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 汽车与汽车的结合*_Wpf_Xaml - Fatal编程技术网

Wpf 汽车与汽车的结合*

Wpf 汽车与汽车的结合*,wpf,xaml,Wpf,Xaml,假设网格有3列: 1st column requires minimum height of 100 to display its content 2nd column requires minimum height of 200 to display its content 3rd column requires minimum height of 300 to display its content 所需总高度为600。如果可用空间为900像素,则额外的300像素应在列之间平均分割,因此最

假设网格有3列:

1st column requires minimum height of 100 to display its content
2nd column requires minimum height of 200 to display its content
3rd column requires minimum height of 300 to display its content
所需总高度为600。如果可用空间为900像素,则额外的300像素应在列之间平均分割,因此最终结果为:

1st column height = 200
2nd column height = 300
3rd column height = 400
如果我使用*设置高度,那么最终结果是每列300像素,这不是我想要的。基本上我需要一个自动和*。这可以在xaml中完成吗?

1st col height=2*

第二列高度=3*

第三列高度=4*

1列高度=2*

第二列高度=3*

第三列高度=4*

试试这个:

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow"
        Height="800"
        Width="525">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"
                           MinHeight="100" />
            <RowDefinition Height="*"
                           MinHeight="200" />
            <RowDefinition Height="*"
                           MinHeight="300" />
        </Grid.RowDefinitions>
        <TextBlock  Background="LightBlue"
                    Text="{Binding ActualHeight, Mode=OneWay, RelativeSource={RelativeSource Self}}" />
        <TextBlock Grid.Row="1"
                   Background="LightCyan"
                   Text="{Binding ActualHeight, Mode=OneWay, RelativeSource={RelativeSource Self}}" />
        <TextBlock Grid.Row="2"
                   Background="LightCoral"
                   Text="{Binding ActualHeight, Mode=OneWay, RelativeSource={RelativeSource Self}}" />
    </Grid>
</Window>

您将看到高度至少为100、200、300,但一旦有足够的位置,额外的位置将平均分配到各行。

尝试以下方法:

<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow"
        Height="800"
        Width="525">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"
                           MinHeight="100" />
            <RowDefinition Height="*"
                           MinHeight="200" />
            <RowDefinition Height="*"
                           MinHeight="300" />
        </Grid.RowDefinitions>
        <TextBlock  Background="LightBlue"
                    Text="{Binding ActualHeight, Mode=OneWay, RelativeSource={RelativeSource Self}}" />
        <TextBlock Grid.Row="1"
                   Background="LightCyan"
                   Text="{Binding ActualHeight, Mode=OneWay, RelativeSource={RelativeSource Self}}" />
        <TextBlock Grid.Row="2"
                   Background="LightCoral"
                   Text="{Binding ActualHeight, Mode=OneWay, RelativeSource={RelativeSource Self}}" />
    </Grid>
</Window>


您将看到高度至少为100、200、300,但一旦有足够的位置,额外的位置将平均分配到各行。

如何将宽度设置为“自动”,将最小宽度设置为100200,以及300?列高度?或者你是说宽度?高度,是的。很抱歉输入错误,但您在问题中写了“列”,您应该将其改为“行”:)行、列、无所谓。:)两者的理念是一样的。我不知道MinWidth,对于不同的内容,它是不同的。将Width设置为“自动”并将MinWidth设置为100200,以及300?列高如何?或者你是说宽度?高度,是的。很抱歉输入错误,但您在问题中写了“列”,您应该将其改为“行”:)行、列、无所谓。:)两者的理念是一样的。我不知道MinWidth,不同内容的MinWidth不同。这不会平均分配位置。这不会平均分配位置。问题是我不知道显示内容所需的最小高度。不同的语言可能会有所不同。这就是为什么我说我需要一个Auto(它将分配刚好足以显示内容的高度)和*(在所有列之间平均分配自由空间)的组合。问题是我不知道显示内容所需的最小高度是多少。不同的语言可能会有所不同。这就是为什么我说我需要一个Auto(它将分配刚好足以显示内容的高度)和*(在所有列之间平均分配自由空间)的组合。