Edward_jie

for you, my Hall of Frame

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
  92 随笔 :: 45 文章 :: 539 评论 :: 43万 阅读
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

出现这个问题,是跟Expanderview中带年纪Header和点击Item程序响应鼠标点击消息两次有关系,即不仅Header接收到了Tap消息,响应之后又讲此Tap消息传递给Item进行了处理,所以出现了,点击空白区域,程序先交给Header处理点击消息,进行了相应处理,然后又交给Item进行消息处理,就会出现意想不到的结果,具体要根据项目中处理鼠标消息写在了Listbox中还是写在Header中还是Item中,或者其中某几项中,根据自己的项目程序如下,和后台代码也有关联,不多赘述了。

如代码PTA项目中的Pivot中的一项:

复制代码
 <controls:PivotItem  Name="Pivot_Phrase" Header="Phrase Book">

<ListBox Name="PhraseList" ItemsSource="{Binding}" VerticalAlignment="Top"
Margin="12,0,0,0">

<!--<ListBox.ItemContainerStyle>
<Style TargetType="ListBoxItem">
<Setter Property="HorizontalContentAlignment" Value="Stretch"/>
</Style>
</ListBox.ItemContainerStyle>-->
<ListBox.ItemTemplate>
<DataTemplate>
<toolkit:ExpanderView Margin="0,0,0,8"
Header="{Binding}"
ItemsSource="{Binding}"
NonExpandableHeader="{Binding}"
IsNonExpandable="{Binding HasSingleMessage}"
Tap="ExpanderView_Tap"
>

<!-- The HeaderTemplate describes the header for an expandable item.
In the sample, it's the TextBlock for "Anne Wallace".-->
<toolkit:ExpanderView.HeaderTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Name="Node" Text="{Binding Title}" Width="300"
Foreground="{StaticResource PhoneForegroundBrush}"
FontSize="{StaticResource PhoneFontSizeExtraLarge}"
FontFamily="{StaticResource PhoneFontFamilySemiLight}"/>
<Image Source="{Binding Arrow}"></Image>
</StackPanel>
</DataTemplate>
</toolkit:ExpanderView.HeaderTemplate>
<toolkit:ExpanderView.ItemTemplate >
<DataTemplate>
<ListBoxItem toolkit:TiltEffect.IsTiltEnabled="True">
<StackPanel>
<TextBlock Text="{Binding Sender}" TextWrapping="Wrap"
Margin="0,8,0,-4" Tap="PhraseList_Tap"
Foreground="{StaticResource PhoneForegroundBrush}"
FontSize="27" Width="400"
FontFamily="{StaticResource PhoneFontFamilySemiLight}"/>
</StackPanel>
</ListBoxItem>
</DataTemplate>
</toolkit:ExpanderView.ItemTemplate>

<toolkit:ExpanderView.NonExpandableHeaderTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" toolkit:TiltEffect.IsTiltEnabled="True">
<TextBlock Text="{Binding Title}" Width="300"
Foreground="{StaticResource PhoneForegroundBrush}"
FontSize="{StaticResource PhoneFontSizeExtraLarge}"
FontFamily="{StaticResource PhoneFontFamilySemiLight}"/>
</StackPanel>
</DataTemplate>
</toolkit:ExpanderView.NonExpandableHeaderTemplate>
</toolkit:ExpanderView>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
</controls:PivotItem>
复制代码

图片中,点击每一项都会有子菜单,有+号的可以展开,代码中第二行 VerticalAlignment="Top"加上之后可以让程序正常运行,未展开时,点击最后一项的下面附近区域,程序不会有相应,如果不加,项目会进入点击最后一项之后的列表项其中一项的状态,

具体效果见本项目PTA的1月10号之前的版本。和1月11号以后的做对比。


 

posted on   Edward_诺  阅读(1053)  评论(1编辑  收藏  举报
编辑推荐:
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
阅读排行:
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· [AI/GPT/综述] AI Agent的设计模式综述
点击右上角即可分享
微信分享提示