인스턴트 메시지를 실버 라이트 빙지도에서 압핀에 바인딩하는 실제적인 두통이 있습니다.빙지도 바인딩 문제
필자는 하루 종일 내 컬렉션을 정렬하려고 노력 했으므로 이제는 압핀이 나타나지 않습니다.
항목은 아래의 이미지에 따라 마지막 줄에 중단 점을 수행 할 때 거기로 표시, 모두 143 개 항목 _pushpins에있다 :
어떤 도움에 오신 것을 환영합니다. 많은 감사.
namespace observable_collection_test
{
public partial class Map : PhoneApplicationPage
{
public Map()
{
InitializeComponent();
GetItems();
}
private ObservableCollection<SItem2> pushPins;
public ObservableCollection<SItem2> PushPins
{
get { return this.pushPins; }
set
{
this.pushPins = value;
this.OnPropertyChanged("PushPins");
}
}
public event PropertyChangedEventHandler PropertyChanged;
public void OnPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
public void GetItems()
{
var document = XDocument.Load("ListSmall.xml");
if (document.Root == null)
return;
var xmlns = XNamespace.Get("http://www.blah");
var events = from ev in document.Descendants("item")
select new
{
Latitude = Convert.ToDouble(ev.Element(xmlns + "Point").Element(xmlns + "lat").Value),
Longitude = Convert.ToDouble(ev.Element(xmlns + "Point").Element(xmlns + "long").Value),
};
this.PushPins = new ObservableCollection<SItem2>();
foreach (var ev in events)
{
var pushPin = new SItem2(ev.Latitude, ev.Longitude);
//Location = new GeoCoordinate(ev.Latitude, ev.Longitude)
this.PushPins.Add(pushPin);
}
}
다른 클래스 : 여기
코드입니다namespace observable_collection_test
{
public class SItem2
{
public double Latitude
{ get; set; }
public double Longitude
{ get; set; }
public SItem2(double Latitude, double Longitude)
{
this.Latitude = Latitude;
this.Longitude = Longitude;
}
public Location Location { get; set; }
}
}
XAML :
<my:Map ZoomBarVisibility="Visible" ZoomLevel="10" CredentialsProvider="xxxxx" Height="508" HorizontalAlignment="Left" Margin="0,22,0,0" Name="map1" VerticalAlignment="Top" Width="456" ScaleVisibility="Visible">
<my:MapItemsControl ItemsSource="{Binding PushPins}" >
<my:MapItemsControl.ItemTemplate>
<DataTemplate>
<my:Pushpin Background="Aqua" Location="{Binding Location}" ManipulationCompleted="pin_click">
</my:Pushpin></DataTemplate>
</my:MapItemsControl.ItemTemplate>
</my:MapItemsControl>
</my:Map>
답변 해 주셔서 감사합니다. 내가 생각할 수있는 코드와 이미지를 편집했습니다. 아직도 기쁨이 없습니다. ObservableCollection PushPins에 대해 일종의 get set accesor가 필요합니까? –
예, 필드가 아닌 속성에만 바인딩 할 수 있습니다. 또한 XAML은 여전히 _PushPins를 참조합니다. – devdigital
XAML을 사용하는 것이 놀랐다는 오류입니다. 모범생 오류. 나는 get/set 접근 자, ive 편집자, 그리고 여전히 기쁨이 무엇인지 잘 모르겠습니다. (전문가에게 명백한 것은 확실합니다 .-) –