Silverlight – Control Inheritance ( Customized Control )
Customized Control Class |
using System; using System.Windows; using System.Windows.Controls; namespace SilverlightPivotViewPDF.Control { public class PivotButton : Button { public String FolderName = ""; public String URL = ""; public PivotButton(int i, String FolderName, String URL) { this.Content = FolderName; this.Margin = new Thickness(10, ((i – 1) * 50) + 10, 0, 0); this.Name = "FolderButton" + i.ToString(); this.Width = 200; this.Height = 40; this.HorizontalAlignment = HorizontalAlignment.Left; this.VerticalAlignment = VerticalAlignment.Top; this.ClickMode = ClickMode.Release; this.FolderName = FolderName; this.URL = URL; this.FontSize = 17; } } } |
Main Class |
PivotButton pbtn; pbtn = new PivotButton(i, itemx.Name, itemx.ServerRelativeUrl); pbtn.Click += Button_Click; this.LayoutRoot.Children.Add(pbtn); |