2010-03-28 3 views
0

코드 숨김을 사용하여 wpf의 이미지에 "imagemaps"를 만들려고합니다. 내 WPF 응용 프로그램의 특정 이미지에 버튼이 번역을 시도하고이미지에 클릭 가능한 영역을 프로그래밍 방식으로 생성

<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> 

:

는 다음과 같은 XML을 참조하십시오.

나는 이미 이것의 일부를 한 적이 있지만 나는 버튼의 "템플릿"으로 다각형 설정에 붙어 :

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(); 
     ????? 
    } 

내가 추가하는 방법에 또한 확실 해요 /이 버튼을 제거 내 이미지에서 /로,하지만 그걸 조사하고 있어요.

도움을 주시면 감사하겠습니다.

답변

0

article by Rob Relyea here을 참조하십시오. 귀하의 질문에 대한 답변입니다.

//Create a button from scratch 
     Button perhapsButton = new Button(); 
     perhapsButton.Content = "Perhaps" 
     perhapsButton.Click += new RoutedEventHandler(perhapsButton_Click); 
     container.Children.Add(perhapsButton); 

버튼 투명도를 0으로 설정하여 보이지 않게 할 수 있습니다.

+0

더 이상이 문제가 해결되었지만 어쨌든 대답으로 표시됩니다. –