ObservableCollection 仅在地图缩放和移动事件上更新,而不添加到集合中!

发布于 2024-10-04 22:00:21 字数 2577 浏览 3 评论 0原文

我对已绑定的集合有疑问。我有一个手动刷新按钮,可以从服务器中拉出一些移动图钉。服务器正在自行移动引脚。处理后,我删除现有集合并将其重新添加到可观察集合中。该代码有效,我已经验证内容已更新,但是如果发生了地图的缩放或移动,则引脚仅“更新”(在地图上移动)!

我的课程如下...

public class MapData : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        private void RaisedPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        private GeoCoordinate mapCenter = new GeoCoordinate(50, -1);

        public GeoCoordinate MapCenter
        {
            get { return this.mapCenter; }
            set
            {
                if (this.mapCenter == value) return;
                this.mapCenter = value;
                this.RaisedPropertyChanged("MapCenter");
            }
        }

        private double zoom = 7.0;
        public double Zoom
        {
            get { return this.zoom; }
            set
            {
                if (this.zoom == value) return;
                this.zoom = value;
                this.RaisedPropertyChanged("Zoom");
            }
        }

        public ObservableCollection<Plane> pins = new ObservableCollection<Plane>() { 

        };

        public ObservableCollection<Plane> Pins
        {
            get { return pins; }
        }

        public void RemovePoints()
        {
            for (int i = 0; i < pins.Count; i++)
            {
                pins.RemoveAt(i);
            }
            pins.Clear();
            this.RaisedPropertyChanged("Location");
        }

       public void AddPoints(List<Plane> Planelist)
        {

            for (int i = 0; i < Planelist.Count; i++) 
            {
                pins.Add(Planelist[i]);
            }

        }



        private Plane selectedPin;
        public Plane SelectedPin
        {
            get {
                return this.selectedPin;
            }
            set
            {
                if (this.selectedPin == value) return;
                this.selectedPin = value;
                this.RaisedPropertyChanged("SelectedPin");

            }
        }

        private LocationCollection routePoints = new LocationCollection();
        public LocationCollection RoutePoints
        {
            get { return routePoints; }
        }

    }

并且使用以下内容进行绑定...

<my:MapItemsControl ItemsSource="{Binding Pins}" ItemTemplate="{StaticResource PushedMe}"/>

I have an issue with a collection that I have bound. I have a manual refresh button that pulls some moving pushpins from the server. The server is moving the pins itself. After processing I delete the existing collection and re add it to the Observable Collection. This code works and I have verififed that the contents have been update however the pins only "update" (move on the map) if a Zoom or move of the map has happened!

My class is as follows...

public class MapData : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        private void RaisedPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
            {
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        private GeoCoordinate mapCenter = new GeoCoordinate(50, -1);

        public GeoCoordinate MapCenter
        {
            get { return this.mapCenter; }
            set
            {
                if (this.mapCenter == value) return;
                this.mapCenter = value;
                this.RaisedPropertyChanged("MapCenter");
            }
        }

        private double zoom = 7.0;
        public double Zoom
        {
            get { return this.zoom; }
            set
            {
                if (this.zoom == value) return;
                this.zoom = value;
                this.RaisedPropertyChanged("Zoom");
            }
        }

        public ObservableCollection<Plane> pins = new ObservableCollection<Plane>() { 

        };

        public ObservableCollection<Plane> Pins
        {
            get { return pins; }
        }

        public void RemovePoints()
        {
            for (int i = 0; i < pins.Count; i++)
            {
                pins.RemoveAt(i);
            }
            pins.Clear();
            this.RaisedPropertyChanged("Location");
        }

       public void AddPoints(List<Plane> Planelist)
        {

            for (int i = 0; i < Planelist.Count; i++) 
            {
                pins.Add(Planelist[i]);
            }

        }



        private Plane selectedPin;
        public Plane SelectedPin
        {
            get {
                return this.selectedPin;
            }
            set
            {
                if (this.selectedPin == value) return;
                this.selectedPin = value;
                this.RaisedPropertyChanged("SelectedPin");

            }
        }

        private LocationCollection routePoints = new LocationCollection();
        public LocationCollection RoutePoints
        {
            get { return routePoints; }
        }

    }

And it is bound using the following...

<my:MapItemsControl ItemsSource="{Binding Pins}" ItemTemplate="{StaticResource PushedMe}"/>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

零崎曲识 2024-10-11 22:00:21

与 Microsoft 交谈后,该设备似乎会缓存 URL,这实际上是我的问题!在服务器端强制无缓存并修复问题!

After speaking with Microsoft it appears that the device will cache URL's and that is actually my issue! Forced no-cache on the server side and issue fixed!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文