小编rul*_*ein的帖子

WPF ListBox的组面板

我有一个列表框,使用GroupStyle对项目进行分组.我想在stackpanel的底部添加一个控件来保存所有组.此附加控件需要是滚动内容的一部分,以便用户滚动到列表的底部以查看控件.如果我使用的是没有组的列表框,则通过修改ListBox模板可以轻松完成此任务.但是,对于分组的项目,ListBox模板似乎仅适用于每个组.我可以修改GroupStyle.Panel,但这不允许我向该面板添加项目.

<ListBox>
<ListBox.ItemsPanel>
    <ItemsPanelTemplate>
        <WrapPanel/>
    </ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.GroupStyle>
    <GroupStyle>
         <GroupStyle.Panel>
             <ItemsPanelTemplate>
                 <VirtualizingStackPanel/>  **<----- I would like to add a control to this stackpanel**
             </ItemsPanelTemplate>
         </GroupStyle.Panel>
        <GroupStyle.ContainerStyle>
            <Style TargetType="{x:Type GroupItem}">
                <Setter Property="Template">
                     <Setter.Value>
                         <ControlTemplate TargetType="{x:Type GroupItem}">
                              <Grid>
                                  <ItemsPresenter />
                              </Grid>
                         </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </GroupStyle.ContainerStyle>
    </GroupStyle>
</ListBox.GroupStyle>
Run Code Online (Sandbox Code Playgroud)

这应该让我知道我需要做什么:

GroupStyleNeeds

wpf listbox groupstyle itemspaneltemplate

4
推荐指数
1
解决办法
6604
查看次数

标签 统计

groupstyle ×1

itemspaneltemplate ×1

listbox ×1

wpf ×1