繁体   English   中英

带有GPS值的WP7动态列表框

[英]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很有帮助

您的NameValue应类似于实现INotifyPropertyChanged接口的NameValue

    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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM