关于windows phone 7开发两个难点求助

近几天看了很多网上的windows phone 7开发的文章,都未能找到能解决我难题的方法,先描述一下,望高手解救。

1、关于longlistselector控件的使用,

  windows phone 7系统里面的人脉具有相同效果,从下往上滑动的时候,人脉里面的索引能停留在顶端。

  网上关于这个控件的使用已经有了很详细的使用方法,包括如何绑定数据,显示数据和效果。各类高手祭出各种高招,已经十分方便得能把数据绑定到longlistselector控件里面,和读取当前选中数据。但是我想要的是一个效果,就是跟windows phone 7系统里面的人脉具有相同效果,当我从下往上滑动的时候,人脉里面的索引能停留在顶端。这个我苦思冥想,都无法解决。

 

View Code
 1 <toolkit:LongListSelector StretchingBottom="longListSelector_StretchingBottom" ScrollingStarted="longListSelector_ScrollingStarted" x:Name="longListSelector" Background="Transparent"
 2  Margin="0,-8,0,0" ShowListHeader="True" SelectionChanged="longListSelector_SelectionChanged" toolkit:TiltEffect.IsTiltEnabled="True" GroupViewOpened="longListSelector_GroupViewOpened">
 3             <toolkit:LongListSelector.GroupItemsPanel>
 4                 <ItemsPanelTemplate>
 5                     <toolkit:WrapPanel Orientation="Horizontal"/>
 6                 </ItemsPanelTemplate>
 7             </toolkit:LongListSelector.GroupItemsPanel>
 8 
 9             <toolkit:LongListSelector.GroupItemTemplate>
10                 <DataTemplate>
11                     <Border Background="Orange" 
12  Width="99" Height="99" Margin="6" IsHitTestVisible="{Binding HasItems}">
13                         <TextBlock Text="{Binding Key}" 
14  FontFamily="{StaticResource PhoneFontFamilySemiBold}"
15  FontSize="48"
16  Margin="8,0,0,0"
17  Foreground="White" 
18  VerticalAlignment="Bottom"/>
19                     </Border>
20                 </DataTemplate>
21             </toolkit:LongListSelector.GroupItemTemplate>
22 
23             <toolkit:LongListSelector.GroupHeaderTemplate>
24                 <DataTemplate>
25                     <Border Background="Transparent" Margin="12,-3,0,8">
26                         <Border Background="Orange" 
27  Width="62" Height="62" 
28  HorizontalAlignment="Left">
29                             <TextBlock HorizontalAlignment="Center" Text="{Binding Key}" 
30  Foreground="#FFFFFF" 
31  FontSize="48"
32  FontFamily="{StaticResource PhoneFontFamilySemiLight}" VerticalAlignment="Center"
33 />
34                         </Border>
35                     </Border>
36                 </DataTemplate>
37             </toolkit:LongListSelector.GroupHeaderTemplate>
38             
39             <toolkit:LongListSelector.ListHeader>
40 
41                     <Border Background="Transparent" Margin="12,-3,0,8">
42                         <Border Background="Transparent" 
43  Width="62" Height="62" 
44  HorizontalAlignment="Left">
45                         <TextBlock HorizontalAlignment="Center" Text="{Binding Key}" 
46  Foreground="#FFFFFF" 
47  FontSize="48"
48  FontFamily="{StaticResource PhoneFontFamilySemiLight}" VerticalAlignment="Center"
49 />
50                         </Border>
51                     </Border>
52        
53             </toolkit:LongListSelector.ListHeader>
54 
55             <toolkit:LongListSelector.ItemTemplate>
56                 <DataTemplate>
57 
58                     <Grid Margin="12,-3,0,8">
59                         <Grid.ColumnDefinitions>
60                             <ColumnDefinition Width="Auto"/>
61                             <ColumnDefinition Width="*"/>
62                         </Grid.ColumnDefinitions>
63                         <Border Background="Gray" 
64  Padding="8,0,0,0" Width="62" Height="62" Grid.Column="0"
65  HorizontalAlignment="Left" Opacity="0.3">
66                         </Border>
67                         <StackPanel Grid.Column="1" VerticalAlignment="Top">
68                             <!--<TextBlock Text="{Binding Name}" Style="{StaticResource PhoneTextLargeStyle}" FontFamily="{StaticResource PhoneFontFamilySemiBold}" Margin="12,-12,12,6"/>-->
69                             <TextBlock Text="{Binding Content}" Style="{StaticResource PhoneTextNormalStyle}" TextWrapping="Wrap" FontSize="48" Foreground="White" />
70                         </StackPanel>
71                     </Grid>
72                 </DataTemplate>
73             </toolkit:LongListSelector.ItemTemplate>
74         </toolkit:LongListSelector>
75     </Grid>

 

2、想要一个跟手机里面新增联系人,选择电话,然后也有一堆的textbox,但是当他聚焦的时候,他会出现滚动条

  关于页面里面有多个textbox(大概5个以上)当我聚焦在第一个时,往往最下面的几个textbox会被挡住,我想要的就是上面的效果,出现滚动条。我也自己尝试过制作滚动条,通过修改scrollviewer的高度来控制滚动,但是,当我点击最后一个textbox的时候,键盘弹出,系统帮我把整个布局往上推上去了,这样就看不到标题了。很是郁闷。求解决。

View Code
 1 <Grid x:Name="LayoutRoot" Background="Transparent">
 2         <Grid.RowDefinitions>
 3             <RowDefinition Height="180"/>
 4             <RowDefinition Height="700"/>
 5         </Grid.RowDefinitions>
 6 
 7         <!--TitlePanel contains the name of the application and page title-->
 8         <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
 9             <TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
10             <TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
11         </StackPanel>
12 
13         <!--ContentPanel - place additional content here-->
14         <StackPanel x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
15             <ScrollViewer VerticalAlignment="Top" x:Name="DemoScrollView" Height="500" SizeChanged="DemoScrollView_SizeChanged">
16                 <StackPanel Height="500">
17                     <TextBlock Text="账号"></TextBlock>
18                     <TextBox x:Name="zhanghao" GotFocus="zhanghao_GotFocus" LostFocus="zhanghao_LostFocus"></TextBox>
19                     <TextBlock Text="密码"></TextBlock>
20                     <TextBox x:Name="mima" GotFocus="mima_GotFocus" LostFocus="mima_LostFocus"></TextBox>
21                     <TextBlock Text="姓名"></TextBlock>
22                     <TextBox x:Name="xingming" GotFocus="xingming_GotFocus" LostFocus="xingming_LostFocus"></TextBox>
23                     <TextBlock Text="性别"></TextBlock>
24                     <TextBox x:Name="xingbie" GotFocus="xingbie_GotFocus" LostFocus="xingbie_LostFocus"></TextBox>
25                     <TextBlock Text="年龄"></TextBlock>
26                     <TextBox x:Name="nianling" GotFocus="nianling_GotFocus" LostFocus="nianling_LostFocus"></TextBox>
27                 </StackPanel>
28             </ScrollViewer>
29         </StackPanel>
30     </Grid>
View Code
 1 private void zhanghao_GotFocus(object sender, RoutedEventArgs e)
 2         {
 3             DemoScrollView.Height = 250;
 4             //DemoScrollView.ScrollToVerticalOffset(0);
 5         }
 6 
 7         private void zhanghao_LostFocus(object sender, RoutedEventArgs e)
 8         {
 9             DemoScrollView.Height = 500;
10         }
11 
12         private void mima_GotFocus(object sender, RoutedEventArgs e)
13         {
14             DemoScrollView.Height = 250;
15             //DemoScrollView.ScrollToVerticalOffset(30);
16         }
17 
18         private void mima_LostFocus(object sender, RoutedEventArgs e)
19         {
20             DemoScrollView.Height = 500;
21         }
22 
23         private void xingming_GotFocus(object sender, RoutedEventArgs e)
24         {
25             DemoScrollView.Height = 250;
26             //DemoScrollView.ScrollToVerticalOffset(50);
27         }
28 
29         private void xingming_LostFocus(object sender, RoutedEventArgs e)
30         {
31             DemoScrollView.Height = 500;
32         }
33 
34         private void xingbie_GotFocus(object sender, RoutedEventArgs e)
35         {
36             DemoScrollView.Height = 250;
37             //DemoScrollView.ScrollToVerticalOffset(80);
38         }
39 
40         private void xingbie_LostFocus(object sender, RoutedEventArgs e)
41         {
42             DemoScrollView.Height = 500;
43         }
44 
45         private void nianling_GotFocus(object sender, RoutedEventArgs e)
46         {
47             DemoScrollView.Height = 250;
48             //DemoScrollView.ScrollToVerticalOffset(100);
49         }
50 
51         private void nianling_LostFocus(object sender, RoutedEventArgs e)
52         {
53             DemoScrollView.Height = 500;
54         }
55 
56         private void DemoScrollView_SizeChanged(object sender, SizeChangedEventArgs e)
57         {
58             if (DemoScrollView.Height == 250)
59             {
60                 //DemoScrollView.ScrollToVerticalOffset(400);
61             }
62         }

因为不知道如何获取到键盘弹出事件,所以用textbox聚焦事件来绕过键盘弹出事件

posted @ 2012-05-16 14:46  (_灬絶℡情乄  阅读(740)  评论(4编辑  收藏  举报