C#实现ControlTemplate方法

藁城网站建设公司创新互联公司,藁城网站设计制作,有大型网站制作公司丰富经验。已为藁城近千家提供企业网站建设服务。企业网站搭建\外贸营销网站建设要多少钱,请找那个售后服务好的藁城做网站的公司定做!
现在主流的控件模板和样式是引用XAML资源,不过感觉没有C#代码实现那么灵活,介绍一下C#实现ControlTemplate方法:
- //控件呈现的显示内容1(这里为Image)
 - FrameworkElementFactoryfe=newFrameworkElementFactory(typeof(Image),"Image");
 - BitmapImagebi=newBitmapImage();
 - bi.BeginInit();
 - bi.UriSource=newUri(@"E:ChartControlHanYangChartControlImageMainBackground.jpg");
 - bi.EndInit();
 - fe.SetValue(Image.SourceProperty,bi);
 - //控件呈现的显示内容2(这里为TextBox)
 - FrameworkElementFactoryfe2=newFrameworkElementFactory(typeof(TextBox),"TextBox");
 - fe2.SetValue(TextBox.WidthProperty,100.0);
 - fe2.SetValue(TextBox.HeightProperty,100.0);
 - //把要呈现的显示内容封装起来
 - FrameworkElementFactoryf=newFrameworkElementFactory(typeof(Grid),"Grid");
 - f.AppendChild(fe);
 - f.AppendChild(fe2);
 - //控件模板
 - ControlTemplatect=newControlTemplate(typeof(Button));
 - ct.VisualTree=f;
 - //修改Button的Template
 - Buttonbtn=newButton();
 - btn.Template=ct;
 
以上介绍C#实现ControlTemplate方法。
                分享名称:C#实现ControlTemplate方法
                
                网站URL:http://www.csdahua.cn/qtweb/news2/181602.html
            
网站建设、网络推广公司-快上网,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 快上网