• 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");
            }


  • 相关阅读:
    linux机器,docker安装mysql
    一次完整的http请求过程
    mac 安装git
    mac下安装maven和IntelliJ IDEA
    小米老手机 安装charles的https证书 MI NOTE LTE
    mac搭建node环境
    python&kafka集群取消息
    mac电脑破解pycharm
    pytest安装
    sql group by 和 定义输出的小数位数
  • 原文地址:https://www.cnblogs.com/walleyekneel/p/3138291.html
Copyright © 2020-2023  润新知