[英]WP7 dynamic ListBox with GPS value
我將嘗試解釋我的問題。對不起,英文翻譯成Google。
我想在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));
}
}
我不知道該怎么辦...幫助預先謝謝
您可以查看如何:從Windows Phone的位置服務 獲取數據, 位置服務示例也非常有用。
它對我如何使用GPS很有幫助
您的Name
和Value
應類似於實現INotifyPropertyChanged
接口的Name
和Value
:
private string name;
[DataMemberAttribute]
public string Name
{
get { return name; }
set
{
if (name != value)
{
name = value;
NotifyPropertyChanged("Name");
}
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.