列表视图中的Wpf扩展器

时间:2015-07-14 07:59:39

标签: c# wpf

我有包含扩展器的列表视图。是否可以在屏幕上进行扩展? enter image description here

 <Grid>
    <ListView ItemsSource="{Binding Items}">
        <ListView.ItemTemplate>
            <DataTemplate>
                <Grid>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition></ColumnDefinition>
                        <ColumnDefinition></ColumnDefinition>
                        <ColumnDefinition></ColumnDefinition>
                        <ColumnDefinition></ColumnDefinition>
                        <ColumnDefinition></ColumnDefinition>
                        <ColumnDefinition></ColumnDefinition>
                        <ColumnDefinition></ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition></RowDefinition>
                    </Grid.RowDefinitions>
                        <Expander Grid.Column="6" Grid.Row="0" Margin="41.343,0,-27,0">
                            <StackPanel>
                                <Label Content="First Element"/>
                                <Label Content="Second Element"/>
                                <Label Content="Third Element"/>
                            </StackPanel>
                        </Expander>
                        <Label Grid.Column="0" Grid.Row="0" Content="Test"/>
                        <Label Grid.Column="1" Grid.Row="0" Content="Test"/>
                        <Label Grid.Column="2" Grid.Row="0" Content="220.35"/>
                        <Label Grid.Column="3" Grid.Row="0" Content="15.37"/>
                        <Label Grid.Column="4" Grid.Row="0" Content="4.54"/>
                        <Label Grid.Column="5" Grid.Row="0" Content="00:04:01"/>
                </Grid>
            </DataTemplate>
        </ListView.ItemTemplate>
    </ListView>
</Grid>

我试图放置&#34; First Element&#34;,&#34; Second Element&#34;,&#34; Third eletment&#34;在网格中并更改其扩展大小,但xaml不允许将网格的左边界放置在扩展器左边界的左侧。

1 个答案:

答案 0 :(得分:0)

以下代码应该作为基础,您需要调整其余的代码以满足您的特定要求,但我所做的是添加一个额外的行,以便您的扩展器可以位于该行并通过行向左扩展整个网格列的长度。

<Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition></ColumnDefinition>
                            <ColumnDefinition></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition></RowDefinition>
                            <RowDefinition></RowDefinition>
                        </Grid.RowDefinitions>
                        <Expander ExpandDirection="Left" Grid.ColumnSpan="6" Grid.Row="1" Margin="41.343,0,-27,0">
                            <StackPanel Orientation="Horizontal">
                                <Label Content="First Element"/>
                                <Label Content="Second Element"/>
                                <Label Content="Third Element"/>
                            </StackPanel>
                        </Expander>
                        <Label Grid.Column="0" Grid.Row="0" Content="Test"/>
                        <Label Grid.Column="1" Grid.Row="0" Content="Test"/>
                        <Label Grid.Column="2" Grid.Row="0" Content="220.35"/>
                        <Label Grid.Column="3" Grid.Row="0" Content="15.37"/>
                        <Label Grid.Column="4" Grid.Row="0" Content="4.54"/>
        <Label Grid.Column="5" Grid.Row="0" Content="00:04:01"/>
    </Grid>