コードビハインドを使用して、wpf の画像に「イメージマップ」を作成しようとしています。
次の 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();
?????
}
このボタンを画像に追加/画像から削除する方法もわかりませんが、調べています。
どんな助けでも大歓迎です。