我会尝试解释我的问题...对于谷歌的英文翻译感到抱歉。
我想动态显示gps listBox中的值
我有一个库存值为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));
}
}
我不知道该怎么做......帮助 提前谢谢
答案 0 :(得分:0)
您可以查看How to: Get Data from the Location Service for Windows Phone,Location Service Sample也非常有用。
帮助我了解如何使用GPS
答案 1 :(得分:0)
您的Name
和Value
应该是这样的,以实现INotifyPropertyChanged
界面:
private string name;
[DataMemberAttribute]
public string Name
{
get { return name; }
set
{
if (name != value)
{
name = value;
NotifyPropertyChanged("Name");
}
}
}