以下是引用片段:
//Control控件呈现显示内容1(这里为Image)
FrameworkElementFactoryfe=FrameworkElementFactory(typeof(Image),"Image");
BitmapImagebi=BitmapImage;
bi.BeginInit;
bi.UriSource=Uri(@"E:ChartControlHanYangChartControlImageMainBackground.jpg");
bi.EndInit;
fe.SetValue(Image.SourceProperty,bi);
//Control控件呈现显示内容2(这里为TextBox)
FrameworkElementFactoryfe2=FrameworkElementFactory(typeof(TextBox),"TextBox");
fe2.SetValue(TextBox.WidthProperty,100.0);
fe2.SetValue(TextBox.HeightProperty,100.0);
//把要呈现显示内容封装起来
FrameworkElementFactoryf=FrameworkElementFactory(typeof(Grid),"Grid");
f.AppendChild(fe);
f.AppendChild(fe2);
//Control控件模板
ControlTemplatect=ControlTemplate(typeof(Button));
ct.VisualTree=f;
//修改ButtonTemplate
Buttonbtn=Button;
btn.Template=ct;
最新评论