扩展器未在ListViewItem中显示内容

时间:2018-08-31 19:48:30

标签: c# wpf xaml listviewitem expander

我具有以下设置,您可以在此处查看

<ListView>
       <ListViewItem x:Name="ItemHome" Height="60">
          <ListViewItem.Content>
              <StackPanel Orientation="Horizontal">
                   <materialDesign:PackIcon
                           Width="25"
                           Height="25"
                           Margin="10"
                           VerticalAlignment="Center"
                           Kind="Database" />
                   <Expander
                           VerticalAlignment="Center"
                           Background="{x:Null}"
                           FontFamily="20"
                           Header="TEST">
                    <Expander.Content>
                           <StackPanel Background="Green" Orientation="Vertical">
                                         <ListViewItem Height="60">
                                            <StackPanel Orientation="Horizontal">
                                               <materialDesign:PackIcon
                                                  Width="25"
                                                  Height="25"
                                                  Margin="10"
                                                  VerticalAlignment="Center"
                                                  Kind="Octagon" />
                                               <TextBlock
                                                  Margin="20,10"
                                                  VerticalAlignment="Center"
                                                  FontFamily="20"
                                                  Text="TEST" />
                                            </StackPanel>
                                         </ListViewItem>
                                         <ListViewItem Height="60">
                                            <StackPanel Orientation="Horizontal">
                                               <materialDesign:PackIcon
                                                  Width="25"
                                                  Height="25"
                                                  Margin="10"
                                                  VerticalAlignment="Center"
                                                  Kind="Needle" />
                                               <TextBlock
                                                  Margin="20,10"
                                                  VerticalAlignment="Center"
                                                  FontFamily="20"
                                                  Text="TEST" />
                                            </StackPanel>
                                         </ListViewItem>
                                      </StackPanel>
                                   </Expander.Content>
                                </Expander>
                             </StackPanel>
                </ListViewItem.Content>
          </ListViewItem>
</ListView>

问题是我相信我以某种方式弄乱了代码,因为当我按下扩展按钮时,什么都没有显示。尝试给扩展器内容指定高度/宽度,但没有运气。扩展器按钮显示他已扩展,但仅此而已。有任何想法吗?谢谢

1 个答案:

答案 0 :(得分:1)

问题是您要设置 ListViewItem Height 属性: enter image description here

这将导致该物品永不生长。删除此分配并进行一些其他调整,您会得到一些奏效(注意:我用ctl:SymbolIcon替换了MaterialDesign:PackIcon,任何人都可以使用任何图标或图像):

// index.js
import forceScreenSize from './forceScreenSize'

// ... other initialization code here
forceScreenSize(270, 480)    

结果: enter image description here