2012-03-28 76 views
-1

我在Silverlight中做了一個應用程序。在那個應用程序中,我想在運行時使用座標繪製一個圓。我已經動態地繪製了這個圓圈,但我想要在特定的座標(X,Y)上畫圓。但我不明白。如何使用座標在silverlight中繪製一個圓圈?

請幫幫我。提前致謝。

回答

0
Ellipse ellipse = new Ellipse() { Width = 150, Height = 150, Stroke = new SolidColorBrush(Colors.Black), 
               HorizontalAlignment = HorizontalAlignment.Center, 
               VerticalAlignment = VerticalAlignment.Center 
      }; 
      ellipse.SetValue(Grid.RowProperty, 0); 
      ellipse.SetValue(Grid.ColumnProperty, 0); 
      this.LayoutRoot.Children.Add(ellipse); 

      TextBlock textblock = new TextBlock() { Text = "Hello", HorizontalAlignment = HorizontalAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; 
      textblock.SetValue(Grid.ColumnProperty, 0); 
      textblock.SetValue(Grid.RowProperty, 0); 
      this.LayoutRoot.Children.Add(textblock); 

而且具有在下面的網站看看.....

http://pietschsoft.com/post/2010/06/28/Silverlight-Bing-Maps-Draw-Circle-Around-Latitude-Longitude-Location.aspx

http://www.kunal-chowdhury.com/2011/07/how-to-create-circular-loader-using.html

希望這篇文章可以幫助你解決你的問題......如果是這樣,請標註它回答...

+0

我寫了相同的代碼,因爲你給了,但如果我將值0更改爲任何其他值,仍然我在相同的位置獲得圓。 ellipse.SetValue(Grid.RowProperty,100); ellipse.SetValue(Grid.ColumnProperty,100); – Dany 2012-03-28 07:46:27

+0

我使用了相同的代碼......它工作..... – 2012-03-28 08:50:16