繁体   English   中英

单击TextBlock打开Expander对象WPF

[英]Click TextBlock to open Expander object WPF

我不太擅长XAML,并且我正在尝试制作以下内容:

图片
(来源: deviantart.net

我需要一些选项(橙色选项),然后单击橙色选项时,它们会展开并显示更多选项。

这是我的小代码:

<ListView Background="#585858" Width="300" HorizontalAlignment="Left">
    <ListViewItem>
        <Grid Margin="15,5">
            <TextBlock Foreground="#FFABADB3" Text="MenuTitle" FontSize="20" Grid.Row="0"/>
            <Expander Grid.Row="1">
            </Expander>
        </Grid>
    </ListViewItem>
</ListView>

但这并不是我想要的那样真正起作用。 Textblock和Expander在同一行上。

这是我的代码:

http://i.imgur.com/dbtNPUv.png

如果有人能指导我正确的方向,我将非常高兴! 在此先感谢您和节日快乐:)

将TextBlock放在Expander Header

<ListView Background="#585858" Width="300" HorizontalAlignment="Left">
 <ListViewItem>
   <Grid Margin="15,5">
     <Expander Grid.Row="1">
      <Expander.Header>
        <TextBlock Foreground="#FFABADB3" Text="MenuTitle" FontSize="20" Grid.Row="0"/>
      </Expander.Header>   
     </Expander>
   </Grid>
 </ListViewItem>
</ListView>

但是,如果您想从图片中进行设计,您将需要做更多的工作。 您将需要“重新模板化” ListViewItemExpander 默认模板与图片上的模板相距甚远。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM