出现这个问题,是跟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号以后的做对比。
分类:
windows phone 7
标签:
windows phone 7
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 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的设计模式综述