LeftPage.cs文件代码: using System; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Media.Imaging; using System.Windows.Shapes; namespace SilverlightClient.TypePage { public class LeftPage : Canvas { //定义将在页面上显示的元素 private Image imgPhoto; private Button btnPrevious; private Rectangle RecBorder; private TextBlock PageNum; //构造函数 public LeftPage() { //页面的设置 this.Width = 452; this.Height = 630; this.Background = new SolidColorBrush(Colors.White); Canvas.SetLeft(this, 0); Canvas.SetTop(this, 0); //页面边框的设置 RecBorder = new Rectangle(); RecBorder.Width = 452; RecBorder.Height = 630; Canvas.SetLeft(RecBorder, 0);//设置页面边框在Canvas中的位置,下同。 Canvas.SetTop(RecBorder, 0); RecBorder.Stroke = new SolidColorBrush(Colors.Black); RecBorder.StrokeThickness = 0; this.Children.Add(RecBorder); //照片的设置 imgPhoto = new Image(); imgPhoto.Width = 450; imgPhoto.Height = 600; Canvas.SetLeft(imgPhoto, 1); Canvas.SetTop(imgPhoto, 1); this.Children.Add(imgPhoto); //“前一页”按钮的设置 btnPrevious = new Button(); btnPrevious.Width = 150; btnPrevious.Height = 20; btnPrevious.Content = "<< 前一页"; btnPrevious.HorizontalContentAlignment = HorizontalAlignment.Center; btnPrevious.VerticalContentAlignment = VerticalAlignment.Center; btnPrevious.Cursor = Cursors.Hand; Canvas.SetLeft(btnPrevious, 151); Canvas.SetTop(btnPrevious, 605); this.Children.Add(btnPrevious); //页码文本的设置 PageNum = new TextBlock(); PageNum.Width = 100; PageNum.Height = 20; PageNum.Text = "00 / 00"; PageNum.TextAlignment = TextAlignment.Left; PageNum.VerticalAlignment = VerticalAlignment.Center; PageNum.FontFamily = new FontFamily("Comic sans MS"); Canvas.SetLeft(PageNum, 10); Canvas.SetTop(PageNum, 607); this.Children.Add(PageNum); } //设置图片路径 public void setterimgPhoto(string path) { BitmapImage btm = new BitmapImage(); btm.UriSource = new Uri(path, UriKind.Relative); imgPhoto.Source = btm; } //设置按钮是否可见 public void setterDisplayBtnPrevious(bool YesNo) { if (YesNo) { btnPrevious.Visibility = Visibility.Visible; } else { btnPrevious.Visibility = Visibility.Collapsed; } } //设置页码 public void setterPageNumber(string currentPageNum, string TotalPageNum) { PageNum.Text = currentPageNum + " / " + TotalPageNum; } //返回按钮单击事件关联 public Button getbtnPrevious() { return btnPrevious; } } } 复制代码 RightPage.cs文件代码: using System; using System.Net; using System.Windows; using System.Windows.Controls; using System.Windows.Documents; using System.Windows.Ink; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Media.Imaging; using System.Windows.Shapes; namespace SilverlightClient.TypePage { public class RightPage : Canvas { //定义将在页面上显示的元素 private Image imgPhoto; private Button btnNext; private Rectangle RecBorder; private TextBlock PageNum; //构造函数 public RightPage() { //页面的设置 this.Width = 452; this.Height = 630; this.Background = new SolidColorBrush(Colors.White); Canvas.SetLeft(this, 0);//设置页面边框在Canvas中的位置,下同。 Canvas.SetTop(this, 0); //页面边框的设置 RecBorder = new Rectangle(); RecBorder.Width = 452; RecBorder.Height = 630; Canvas.SetLeft(RecBorder, 0); Canvas.SetTop(RecBorder, 0); RecBorder.Stroke = new SolidColorBrush(Colors.Black); RecBorder.StrokeThickness = 0; this.Children.Add(RecBorder); //照片的设置 imgPhoto = new Image(); imgPhoto.Width = 450; imgPhoto.Height = 600; Canvas.SetLeft(imgPhoto, 1); Canvas.SetTop(imgPhoto, 1); this.Children.Add(imgPhoto); //“后一页”按钮的设置 btnNext = new Button(); btnNext.Width = 150; btnNext.Height = 20; btnNext.Content = "后一页 >>"; btnNext.HorizontalContentAlignment = HorizontalAlignment.Center; btnNext.VerticalContentAlignment = VerticalAlignment.Center; btnNext.Cursor = Cursors.Hand; Canvas.SetLeft(btnNext, 151); Canvas.SetTop(btnNext, 605); this.Children.Add(btnNext); //页码文本的设置 PageNum = new TextBlock(); PageNum.Width = 100; PageNum.Height = 20; PageNum.Text = "00 / 00"; PageNum.TextAlignment = TextAlignment.Right; PageNum.VerticalAlignment = VerticalAlignment.Center; PageNum.FontFamily = new FontFamily("Comic sans MS"); Canvas.SetLeft(PageNum, 340); Canvas.SetTop(PageNum, 607); this.Children.Add(PageNum); } //设置图片路径 public void setterimgPhoto(string path) { BitmapImage btm = new BitmapImage(); btm.UriSource = new Uri(path, UriKind.Relative); imgPhoto.Source = btm; } //设置按钮是否可见 public void setterDisplayBtnNext(bool YesNo) { if (YesNo) { btnNext.Visibility = Visibility.Visible; } else { btnNext.Visibility = Visibility.Collapsed; } } //设置页码 public void setterPageNumber(string currentPageNum, string TotalPageNum) { PageNum.Text = currentPageNum + " / " + TotalPageNum; } //返回按钮单击事件关联 public Button getbtnNext() { return btnNext; } } }