0
我試圖在使用代碼隱藏的wpf中的圖像上創建「imagemaps」。以編程方式在圖像上創建可點擊區域
請參閱下面的XML:
<Button Type="Area">
<Point X="100" Y="100"></Point>
<Point X="100" Y="200"></Point>
<Point X="200" Y="200"></Point>
<Point X="200" Y="100"></Point>
<Point X="150" Y="150"></Point>
</Button>
我想這個轉換爲一個按鈕,在我的WPF應用程序一定的圖像上。
我已經做了這項工作的一部分,但我卡在設置多邊形作爲按鈕的「模板」:
private Button GetAreaButton(XElement buttonNode)
{
// get points
PointCollection buttonPointCollection = new PointCollection();
foreach (var pointNode in buttonNode.Elements("Point"))
{
buttonPointCollection.Add(new Point((int)pointNode.Attribute("X"), (int)pointNode.Attribute("Y")));
}
// create polygon
Polygon myPolygon = new Polygon();
myPolygon.Points = buttonPointCollection;
myPolygon.Stroke = Brushes.Yellow;
myPolygon.StrokeThickness = 2;
// create button based on polygon
Button button = new Button();
?????
}
我對如何添加也不能確定/刪除此按鈕去/從我的形象,但我正在調查。
任何幫助表示讚賞。
不知道了,如果這固定它,但我標記爲答案無論如何.. – 2010-09-14 09:09:27