如何在扩展器头中创建空的扩展网格列

时间:2011-07-18 18:12:27

标签: wpf

我正在尝试创建一个自定义扩展器标头,它将在左侧显示一个文本框,在右侧显示其他几个文本框,随着窗口水平增长,左右文本块变得更加分开。感觉这应该有效,但一切都保持合理。

<Expander.Header>
    <Grid HorizontalAlignment="Stretch">
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto" Name="LeftJustifiedCol" ></ColumnDefinition>
            <ColumnDefinition Width="*" Name="EmptySpaceCol" ></ColumnDefinition>
            <ColumnDefinition Width="Auto" Name="RightJustifiedCol" ></ColumnDefinition>
        </Grid.ColumnDefinitions>
        <TextBlock Grid.Column="0" Margin="5,0,5,0" Text="{Binding GroupByValue}"></TextBlock>
        <DockPanel Grid.Column="2" HorizontalAlignment="Right">
            <TextBlock DockPanel.Dock="Right" Margin="5,0,5,0"  Text="Net: $0.00"></TextBlock>
            <Button DockPanel.Dock="Right" Margin="5,0,5,0" Width="Auto" Name="DeleteEntityBtn" Click="DeleteEntityBtn_Click" >Del</Button>
        </DockPanel>
    </Grid>
</Expander.Header>

<Expander.Header> <Grid HorizontalAlignment="Stretch"> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto" Name="LeftJustifiedCol" ></ColumnDefinition> <ColumnDefinition Width="*" Name="EmptySpaceCol" ></ColumnDefinition> <ColumnDefinition Width="Auto" Name="RightJustifiedCol" ></ColumnDefinition> </Grid.ColumnDefinitions> <TextBlock Grid.Column="0" Margin="5,0,5,0" Text="{Binding GroupByValue}"></TextBlock> <DockPanel Grid.Column="2" HorizontalAlignment="Right"> <TextBlock DockPanel.Dock="Right" Margin="5,0,5,0" Text="Net: $0.00"></TextBlock> <Button DockPanel.Dock="Right" Margin="5,0,5,0" Width="Auto" Name="DeleteEntityBtn" Click="DeleteEntityBtn_Click" >Del</Button> </DockPanel> </Grid> </Expander.Header>

有什么建议吗?

1 个答案:

答案 0 :(得分:0)

我猜WPF没有呈现中间列,因为它不包含内容,所以它在UI中不占用空间。也许具有LastChildFill="False"的DockPanel比Grid

更好