1

请帮助,网格拆分器未正确拆分到右侧,测试按钮内容。使用网格拆分器有什么我错过的吗?

<local:LayoutTemplateSelector Content="{Binding}">
                    <local:LayoutTemplateSelector.VerticalLeftRight>
                        <DataTemplate>
                            <Grid ShowGridLines="True" Background="Orange"  Height="{Binding Height}" 
                                  HorizontalAlignment="Stretch" VerticalAlignment="Stretch" >
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width=".25*"/>
                                    <ColumnDefinition Width="10" />
                                    <ColumnDefinition Width=".70*"/>

                                </Grid.ColumnDefinitions>
                                <Button  Grid.Column="0" Content="Test"  Width="{Binding ChartWidth}" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"/>
                                <sdk:GridSplitter Grid.Column="1" ShowsPreview="True" VerticalAlignment="Stretch" HorizontalAlignment="Stretch"/>
                                <Button Content="Testing"  Width="{Binding SectionWidth}"  Grid.Column="2"
                                    HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                                    HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"/>
                            </Grid>
                        </DataTemplate>
                    </local:LayoutTemplateSelector.VerticalLeftRight>
                </local:LayoutTemplateSelector>
4

1 回答 1

1

您需要为第一列使用固定宽度,为剩余的列使用星号。

<Grid.ColumnDefinitions>
             <ColumnDefinition Width="200" MinWidth="50" MaxWidth="250"/>
             <ColumnDefinition Width="10" />
             <ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>

为第一列设置最小值和最大值以使其看起来合理通常是一个好主意(但不是必需的)。

于 2011-06-30T07:43:03.563 回答