【问题标题】:How to add radio buttons dynamically and display them in a button click in map control(windows phone 8.1)如何动态添加单选按钮并在地图控件中单击按钮显示它们(windows phone 8.1)
【发布时间】:2015-10-22 04:03:29
【问题描述】:

在我的地图控件中有多个带有按钮的位置。因此,当我单击该位置中的特定按钮时,地图控件中应显示两个单选按钮。

                BasicGeoposition bgp = new BasicGeoposition();

                AppBarButton rd = new AppBarButton();
                bgp.Latitude = loct.lat;
                bgp.Longitude = loct.lng;
                Geopoint hwPoint = new Geopoint(bgp);
                MapControl.SetLocation(rd, hwPoint);
                MapControl.SetNormalizedAnchorPoint(rd, new Point(0.5, 0.5));

                map1.Children.Add(rd);

通过这种方式,我向地图控件添加了按钮。在那个 rd_click 我应该如何实现在那个位置显示单选按钮

  void rd_Click(object sender, RoutedEventArgs e)
    {
        RadioButton rb = new RadioButton();
        RadioButton rb1 = new RadioButton();
        StackPanel st = new StackPanel();
        st.Children.Add(rb);
        st.Children.Add(rb1);
        // I want to add this stackpanel to the mapcontrol
    }

在按钮附近,两个单选按钮应显示在地图控件中。请帮帮我

错误显示在link

【问题讨论】:

    标签: c# xaml windows-phone-8.1 bing-maps


    【解决方案1】:

    首先,您需要设置 StackPanel 的位置,然后将其添加为地图的子项,如下所示:

    MapControl.SetLocation(st, new Geopoint(/* Your location info */));
    MyMap.Children.Add(st);
    

    【讨论】:

    • 添加我在您的代码中提供的代码,其中您有注释 //我想将此堆栈面板添加到地图控件。
    • 我无法访问 Geopoint。你能告诉我如何将此地理点传递给 rd_click 事件
    • 我的意思是如何将GeoPoint参数传递给点击事件
    • 给你:var loc = MapControl.GetLocation(sender as AppBarButton);
    • 感谢您的友好回复。我帮了我很多
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-07
    相关资源
    最近更新 更多