Silverlight 4.0:GridSplitter分割错误

时间:2011-06-30 03:58:15

标签: silverlight silverlight-4.0 gridsplitter

请帮忙,网格分割器中没有正确分割到正确的测试按钮内容。有没有我错过使用网格分割器的东西?

<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>

1 个答案:

答案 0 :(得分:1)

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

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

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