您的位置:首页 > 其它

解决windows phone 7 toolkit中Expanderview点击未展开的可展开列表项题目下边缘空白出现响应的问题

2012-01-11 23:02 357 查看
出现这个问题,是跟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号以后的做对比。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐