本文整理汇总了C#中System.Windows.Controls.Label.ApplyTemplate方法的典型用法代码示例。如果您正苦于以下问题:C# Label.ApplyTemplate方法的具体用法?C# Label.ApplyTemplate怎么用?C# Label.ApplyTemplate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.Label
的用法示例。
在下文中一共展示了Label.ApplyTemplate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
public void Init(ProdClickHandler h,bool CanDelete)
{
this.phandler = h;
this.wrapPanel1.Children.Clear();
PackerConfig pcfg = new PackerConfig();
foreach (string id in curr_packer.pkg_confs.Keys)
{
pcfg.FromElement(curr_packer.pkg_confs[id]);
FileInfo fi;
if (File.Exists(ProdNum.baseDir + "\\prodpic\\" + StringResource.language + "\\" + pcfg.product_desc + ".jpg"))
{
fi = new FileInfo(ProdNum.baseDir + "\\prodpic\\" + StringResource.language + "\\" + pcfg.product_desc + ".jpg");
}
else
{
fi = new FileInfo(ProdNum.baseDir + "\\prodpic\\default.jpg");
}
imglist[id] = fi.FullName;
Label n = new Label();
ControlTemplate ct = this.FindResource("imgBtn") as ControlTemplate;
n.Template = ct;
n.Name = "ID" + id;
//Product num: Pru
n.Content = String.Format("{0}:{1}\n{2}:{3}\n{4}:{5}\n{6}:{7}\n{8}:{9}",
StringResource.str("product_no"),pcfg.product_no,
StringResource.str("product_desc"),pcfg.product_desc,
StringResource.str("grp_target"),pcfg.target,
StringResource.str("grp_uvar"),pcfg.upper_var,
StringResource.str("grp_dvar"),pcfg.lower_var
);
//n.Click += ImageSelected;
n.ApplyTemplate();
Rectangle rectimg = ct.FindName("ImageRect", n) as Rectangle;
rectimg.Name = "Rt" + id;
Button delBtn = ct.FindName("DelBtn", n) as Button;
delBtn.Name = "De" + id;
rectimg.MouseLeftButtonUp += ImageRect_MouseLeftButtonUp;
delBtn.Click += Delbtn_Click;
if (!CanDelete)
delBtn.Visibility = Visibility.Hidden;
ImageBrush ib = ct.FindName("ImageFill", n) as ImageBrush;
ib.ImageSource = new BitmapImage(new Uri(fi.FullName));
this.wrapPanel1.Children.Add(n);
}
this.Show();
}