• WFP page navigator control


    WPF navigator

    UI:
    
    <Grid x:Class="WpfApplication2.PagerNav"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
                 mc:Ignorable="d" 
                 d:DesignHeight="68" d:DesignWidth="652">
        <Grid>
            <Grid Background="WhiteSmoke" Height="33" VerticalAlignment="Center" HorizontalAlignment="Center" Width="333">
                <TextBox HorizontalAlignment="Left" Width="61" Height="26" Margin="197,0,0,0" Name="txtPageNum" Text="1"></TextBox>
                <Button Content="prev" VerticalAlignment="Center" Height="28" HorizontalAlignment="Left" Margin="6,0,0,0" Name="btnPrev" IsEnabled="True"  Width="89" Click="btnPrev_Click" />
                <Button Content="next" VerticalAlignment="Center" Height="28" HorizontalAlignment="Left" Margin="101,0,0,0" Name="btnNext" IsEnabled="True"  Width="89" Click="btnNext_Click" />
                <Button Content="go" VerticalAlignment="Center" Height="28" HorizontalAlignment="Left" Margin="261,0,0,0" Name="btnGo" IsEnabled="True"  Width="64" Click="btnGo_Click" />
    
    
            </Grid>
        </Grid>
    </Grid>
    
    
    Code:
    
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    
    namespace WpfApplication2
    {
        /// <summary>
        /// Interaction logic for PagerNav.xaml
        /// </summary>
        public partial class PagerNav : Grid
        {
            public PagerNav()
            {
                InitializeComponent();
            }
    
            public int pageIndex = 1;
            public  void btnPrev_Click(object sender, RoutedEventArgs e)
            {
                pageIndex--;
                if (pageIndex < 1) {
                    pageIndex = 1;
                }
                txtPageNum.Text =""+ pageIndex;
            }
    
            private void btnNext_Click(object sender, RoutedEventArgs e)
            {
                pageIndex++;
                txtPageNum.Text = "" + pageIndex;
            }
    
            private void btnGo_Click(object sender, RoutedEventArgs e)
            {
    
                pageIndex = int.Parse("" + txtPageNum.Text);
    
            }
    
    
    
    
        }
    }
    
    
    
    
    
    
    
    Main window use:
    
    
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Documents;
    using System.Windows.Input;
    using System.Windows.Media;
    using System.Windows.Media.Imaging;
    using System.Windows.Navigation;
    using System.Windows.Shapes;
    
    namespace WpfApplication2
    {
        /// <summary>
        /// Interaction logic for UserControl1.xaml
        /// </summary>
        public partial class UserControl1 : UserControl
        {
            public UserControl1()
            {
                InitializeComponent();
                pagerNav1.btnPrev.Click += new RoutedEventHandler(PagerNav_Click);
                pagerNav1.btnNext.Click += new RoutedEventHandler(PagerNav_Click);
                pagerNav1.btnGo.Click += new RoutedEventHandler(PagerNav_Click);
            }
    
            void PagerNav_Click(object sender, RoutedEventArgs e)
            {
    
                //lbPager.Content =("out" + pagerNav1.pageIndex);
                // do LoadPage(pagerNav1.pageIndex);
    
            }
        }
    }
    

      

  • 相关阅读:
    解决C#程序只允许运行一个实例的几种方法详解
    C# static const和readonly区别
    c# string.format和tostring()
    DataTable与实体类互相转换
    java switch语句 要点注意
    java 运算符&表达式
    java数据类型(大小等),变量定义,各进制书写方法
    Java标识符(Identifier)(关键字和保留字)
    关于美剧《越狱》
    一些四六级的事
  • 原文地址:https://www.cnblogs.com/wgscd/p/9599010.html
Copyright © 2020-2023  润新知