zoukankan      html  css  js  c++  java
  • wp7 listbox底部显示加载更多

    http://www.bbniu.com/thread-1569-1-1.html

    前台XAML代码:

    <phone:PhoneApplicationPage 
        x:Class="DemoApp.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
        xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
        FontFamily="{StaticResource PhoneFontFamilyNormal}"
        FontSize="{StaticResource PhoneFontSizeNormal}"
        Foreground="{StaticResource PhoneForegroundBrush}"
        SupportedOrientations="Portrait" Orientation="Portrait"
        shell:SystemTray.IsVisible="True" Loaded="PhoneApplicationPage_Loaded">
    	<phone:PhoneApplicationPage.Resources>
    		
    	</phone:PhoneApplicationPage.Resources>
    
        <!--LayoutRoot is the root grid where all page content is placed-->
        <Grid x:Name="LayoutRoot" Background="Transparent">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
    
            <!--TitlePanel contains the name of the application and page title-->
            <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
                <TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION" Style="{StaticResource PhoneTextNormalStyle}"/>
                <TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
            </StackPanel>
    
            <!--ContentPanel - place additional content here-->
            <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
                <ListBox Name="listBox1" VerticalAlignment="Top">
                    <ListBox.Template>
                        <ControlTemplate TargetType="ListBox" >
                            <ScrollViewer x:Name="ScrollViewer" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" Foreground="{TemplateBinding Foreground}" Padding="{TemplateBinding Padding}">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition></RowDefinition>
                                        <RowDefinition></RowDefinition>
                                    </Grid.RowDefinitions>
                                    <ItemsPresenter Grid.Row="0"/>
                                    <Button Click="Button_Click" Background="Transparent" BorderThickness="0" Content="更多" Grid.Row="1"></Button>
                                </Grid>
                            </ScrollViewer>
                        </ControlTemplate>
                    </ListBox.Template>
                </ListBox>
            </Grid>
        </Grid>
     
        <!--Sample code showing usage of ApplicationBar-->
        <!--<phone:PhoneApplicationPage.ApplicationBar>
            <shell:ApplicationBar BackgroundColor="Blue" ForegroundColor="Yellow" IsVisible="True" IsMenuEnabled="True">
                <shell:ApplicationBarIconButton IconUri="/icons/appbar.check.rest.png" Text="Button 1"/>
                <shell:ApplicationBarIconButton IconUri="/icons/appbar.cancel.rest.png" Text="Button 2"/>
            </shell:ApplicationBar>
        </phone:PhoneApplicationPage.ApplicationBar>-->
    
    </phone:PhoneApplicationPage>
    


    后台代码只需在MainPage的构造函数中增添一点代码:

            // Constructor
            public MainPage()
            {
                InitializeComponent();
    
                // 绑定ListBox的Items
                List<string> list = new List<string>();
                for (int i = 0; i < 50; i++)
                {
                    list.Add(i.ToString());
                }
                listBox1.ItemsSource = list;
            }
    


    然后实现一下[更多]按钮的行为:

            private void Button_Click(object sender, RoutedEventArgs e)
            {
                MessageBox.Show("More");
            }


  • 相关阅读:
    【WEBI专题】解决在交叉表中计算占比、偏差、率的问题
    前导零的问题(增加/删除)
    在SAP BW中使用ABAP
    如何组织维度
    BEx Query Designer中的变量及其增强
    《魔幻手机》经典台词摘录
    今天发现了VISTA系统的一个BUG
    Online Tools And Sofrware Directory Entry
    [转载]博客园通过Word 2007发布随笔
    为你的程序增加记忆功能
  • 原文地址:https://www.cnblogs.com/walleyekneel/p/3138291.html
Copyright © 2011-2022 走看看