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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ionic-framework/2.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,我有一个简单的XAML <Grid x:Name="LayoutRoot" Background="White" HorizontalAlignment="Stretch"> <Grid.RowDefinitions> <RowDefinition Height="100"/> <RowDefinition Height="100"/> </Grid.RowDefinitions>

我有一个简单的XAML

<Grid x:Name="LayoutRoot" Background="White" HorizontalAlignment="Stretch">
    <Grid.RowDefinitions>
        <RowDefinition Height="100"/>
        <RowDefinition Height="100"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="Auto"/>
    </Grid.ColumnDefinitions>

    <Rectangle Grid.Column="0" Fill="LightCoral" MinWidth="100"/>
    <Rectangle Grid.Column="1" Fill="LightBlue" MinWidth="100"/>
    <Rectangle Grid.Column="2" Fill="LightCoral" MinWidth="100"/>
    <Rectangle Grid.Column="3" Fill="Gray" MinWidth="100"/>
    <Rectangle Grid.Column="4" Fill="LightCoral" MinWidth="100"/>

    <GridSplitter Grid.Column="0" Grid.RowSpan="2" Width="10" HorizontalAlignment="Right" VerticalAlignment="Stretch"/>
    <GridSplitter Grid.Column="1" Grid.RowSpan="2" Width="10" HorizontalAlignment="Right" VerticalAlignment="Stretch"/>
    <GridSplitter Grid.Column="2" Grid.RowSpan="2" Width="10" HorizontalAlignment="Right" VerticalAlignment="Stretch"/>
    <GridSplitter Grid.Column="3" Grid.RowSpan="2" Width="10" HorizontalAlignment="Right" VerticalAlignment="Stretch"/>
    <GridSplitter Grid.Column="4" Grid.RowSpan="2" Width="10" HorizontalAlignment="Right" VerticalAlignment="Stretch"/>

</Grid>


这一行很好,但是我想要第二列(保存浅蓝色矩形的列)来填充所有可用的宽度。如果我设置第二列definition.Width=“*”-然后将GridSplitters设置到它的右侧,比如说灰色矩形的GridSplitter-它开始运行得非常wierd,这与我想要的完全不同。是否可以使GridSplitter的行为类似于DataGrid的列标题?

GridSplitter
控件创建单独的列

<Grid x:Name="LayoutRoot" Background="White">
    <Grid.RowDefinitions>
        <RowDefinition Height="100"/>
        <RowDefinition Height="100"/>
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="3*"/>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="*"/>
        <ColumnDefinition Width="Auto"/>
        <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>

    <Rectangle Grid.Column="0" Fill="LightCoral" MinWidth="100"/>
    <Rectangle Grid.Column="2" Fill="LightBlue"/>
    <Rectangle Grid.Column="4" Fill="LightCoral" MinWidth="100"/>
    <Rectangle Grid.Column="6" Fill="Gray" MinWidth="100"/>
    <Rectangle Grid.Column="8" Fill="LightCoral" MinWidth="100"/>

    <GridSplitter Grid.Column="1" Grid.RowSpan="2" 
                  Width="10" HorizontalAlignment="Right" VerticalAlignment="Stretch"
                  ResizeDirection="Columns" ResizeBehavior="PreviousAndNext"/>
    <GridSplitter Grid.Column="3" Grid.RowSpan="2" 
                  Width="10" HorizontalAlignment="Right" VerticalAlignment="Stretch"
                  ResizeDirection="Columns" ResizeBehavior="PreviousAndNext"/>
    <GridSplitter Grid.Column="5" Grid.RowSpan="2" 
                  Width="10" HorizontalAlignment="Right" VerticalAlignment="Stretch"
                  ResizeDirection="Columns" ResizeBehavior="PreviousAndNext"/>
    <GridSplitter Grid.Column="7" Grid.RowSpan="2" 
                  Width="10" HorizontalAlignment="Right" VerticalAlignment="Stretch"
                  ResizeDirection="Columns" ResizeBehavior="PreviousAndNext"/>

</Grid>


没有,我几乎看不到任何变化。至少当我尝试设置ColumnDefinition[2]时,Width=“*”-它仍然正常工作wrong@AlexeyTitov我想我明白你的意思了。您可以尝试使用*作为列宽吗?我知道这与您当前的初始列大小不同,但效果更好。是的,不是我想要的,但您的答案仍然适用于初始AR 16:9或16:10的项目规格。谢谢