ArcGIS API for Silverlight 點選地圖上的要素,彈出視窗(使用Telerik RadWindow)

暖楓無敵發表於2012-05-30

xmlns:telerikNavigation="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.Navigation"
xmlns:telerik="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls"

 <!-- 詳情資訊顯示視窗-->
<telerikNavigation:RadWindow x:Name="RadWindow1"  Tag="詳情" BorderBackground="#B4DEFE" Width="520"   Height="330"  LocationChanged="RadWindow1_LocationChanged" WindowState="Maximized">
         <telerik:RadHtmlPlaceholder x:Name="moreInfo" SourceUrl="" />
</telerikNavigation:RadWindow>

#region 處理彈出視窗公共類

        public void ClickOpenDetailInfo(string name, string url)
        {
            TextBlock textBlock = new TextBlock();
            moreInfo.Height = 541;
            moreInfo.SourceUrl = new Uri(url, UriKind.Relative);
            string tmp = string.Empty;
             tmp = name + "詳細資訊";
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < tmp.Length; i++)
            {
                sb.Append(tmp[i] + " ");
            }
            textBlock.Text = sb.ToString();
            textBlock.FontSize = 16;
            textBlock.FontWeight = FontWeights.Black;
            SolidColorBrush scbrush = new SolidColorBrush();
            scbrush.Color = Colors.Black;
            textBlock.Foreground = scbrush;

            textBlock.HorizontalAlignment = HorizontalAlignment.Center;
            RadWindow1.Header = textBlock;
            RadWindow1.Show();
        }


        private void RadWindow1_LocationChanged(object sender, RoutedEventArgs e)
        {
            moreInfo.InvalidateArrange();
        }


        #endregion

//左鍵選單
graphic.MouseLeftButtonDown += new MouseButtonEventHandler(sw_graphic_MouseLeftButtonDown);
 graphic.MouseLeftButtonUp += new MouseButtonEventHandler(sw_graphic_MouseLeftButtonUp);

void sw_graphic_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
         e.Handled = true;
}

 void sw_graphic_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
            Graphic g = sender as Graphic;
            string url = "../ysq/page2.aspx?stype=2&ylz=" + HttpUtility.UrlEncode(g.Attributes["YLZMC"].ToString());
            //彈出窗體
            ClickOpenDetailInfo(g.Attributes["YLZMC"].ToString(), url);
}


效果如下圖,這個視窗能保證每次只彈出一個。


相關文章