带有GPS值的WP7动态列表框
本文关键字:列表 动态 WP7 GPS 值的 带有 | 更新日期: 2023-09-27 18:26:23
我会尽力解释我的问题。。。抱歉把英文翻译成谷歌。
我想动态显示这些值在gps列表框中
我有一个股票估值的类gps:
public class LocationManager : INotifyPropertyChanged
另一个名称和价值:
public class GpsItem: INotifyPropertyChanged
第三类:
public class GpsItems: ObservableCollection<GpsItem>
我的列表框,将ItemsSource作为我的第三类
ListBox.ItemsSource = new GpsItems();
xaml:
<ListBox x:Name="ListBox" Background="#BF000000" Tap="LsbAllCases_Tap">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Margin="0,0,0,10" Width="Auto" Height="Auto" Orientation="Horizontal">
<TextBlock Text="{Binding Name, Mode="OneWay"}" VerticalAlignment="Center" HorizontalAlignment="Left" />
<TextBlock Text="{Binding Value, Mode="OneWay"}" HorizontalAlignment="Right" />
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
执行中显示的值,但不是动态的。
我已经用实现了INotifyPropertyChanged接口
// Declare the PropertyChanged event
public event PropertyChangedEventHandler PropertyChanged;
// NotifyPropertyChanged will raise the PropertyChanged event passing the
// source property that is being updated.
public void NotifyPropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
我不知道该怎么办。。。帮助提前感谢
您的Name
和Value
应该像这样来实现INotifyPropertyChanged
接口:
private string name;
[DataMemberAttribute]
public string Name
{
get { return name; }
set
{
if (name != value)
{
name = value;
NotifyPropertyChanged("Name");
}
}
}
您可以查看如何:从Windows Phone的定位服务获取数据,定位服务示例也非常有用。
它帮助我了解了如何使用GPS