के माध्यम से बिंग मैप्स में पुशपिन में टेक्स्ट जोड़ना मैं अपनी चांदी की रोशनी बनाने में सक्षम था बिंग नक्शा मूसक्लिक स्वीकार करता है और उन्हें सी # में पुष्पिन में परिवर्तित करता है। अब मैं पुशपिन के बगल में एक टेक्स्ट दिखाना चाहता हूं जो वर्णन करता है कि जब माउस पिन पर जाता है, तो मुझे कोई संकेत नहीं है कि यह कैसे करें। ऐसी चीजें हैं जो मुझे यह करने में सक्षम बनाती हैं?सिल्वरलाइट - सी #
यह सी # कोड है:
public partial class MainPage : UserControl
{ निजी MapLayer m_PushpinLayer;
(1) PushPinLayer.AddChild में पारित करने के लिए किसी भी UIElement बनाएँ:
public MainPage()
{
InitializeComponent();
base.Loaded += OnLoaded;
}
private void OnLoaded(object sender, RoutedEventArgs e)
{
base.Loaded -= OnLoaded;
m_PushpinLayer = new MapLayer();
x_Map.Children.Add(m_PushpinLayer);
x_Map.MouseClick += OnMouseClick;
}
private void AddPushpin(double latitude, double longitude)
{
Pushpin pushpin = new Pushpin();
pushpin.MouseEnter += OnMouseEnter;
pushpin.MouseLeave += OnMouseLeave;
m_PushpinLayer.AddChild(pushpin, new Location(latitude, longitude), PositionOrigin.BottomCenter);
}
private void OnMouseClick(object sender, MapMouseEventArgs e)
{
Point clickLocation = e.ViewportPoint;
Location location = x_Map.ViewportPointToLocation(clickLocation);
AddPushpin(location.Latitude, location.Longitude);
}
private void OnMouseLeave(object sender, MouseEventArgs e)
{
Pushpin pushpin = sender as Pushpin;
// remove the pushpin transform when mouse leaves
pushpin.RenderTransform = null;
}
private void OnMouseEnter(object sender, MouseEventArgs e)
{
Pushpin pushpin = sender as Pushpin;
// scaling will shrink (less than 1) or enlarge (greater than 1) source element
ScaleTransform st = new ScaleTransform();
st.ScaleX = 1.4;
st.ScaleY = 1.4;
// set center of scaling to center of pushpin
st.CenterX = (pushpin as FrameworkElement).Height/2;
st.CenterY = (pushpin as FrameworkElement).Height/2;
pushpin.RenderTransform = st;
}
}
धन्यवाद जिम .. यह बहुत उपयोगी था :) यह पहले काम नहीं करता .. जब तक मैंने ग्रिड नहीं बदला। ग्रिड में जोड़ें। चिल्ड्रे एन। जोड़ें ... फिर से धन्यवाद! – Morano88