【发布时间】:2011-02-01 18:35:09
【问题描述】:
如何以编程方式设置按钮的模板?
Polygon buttonPolygon = new Polygon();
buttonPolygon.Points = buttonPointCollection;
buttonPolygon.Stroke = Brushes.Yellow;
buttonPolygon.StrokeThickness = 2;
// create ControlTemplate based on polygon
ControlTemplate template = new ControlTemplate();
template.Childeren.Add(buttonPolygon); // This does not work! What's the right way?
//create button based on controltemplate
Button button = new Button();
button.Template = template;
所以我需要一种方法来将我的多边形设置为按钮的模板。有什么建议吗?
谢谢。
【问题讨论】:
标签: wpf code-behind controltemplate