容易依赖的属性有疑问吗? [英] Easy Dependency Property Question?

查看:66
本文介绍了容易依赖的属性有疑问吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我认为这是一个简单的问题-但这让我很困扰!

我在包装Google地图的控件中有一个名为``Location''的依赖项属性.单击地图时,我设置了属性,这很好用.但是,当其他设置属性时,我需要更新地图上的位置-如何知道依赖属性的方向"?例如:

Hi Guys,

I think this is an easy question - but it''s stumped me!

I have a dependency property called ''Location'' in a control that wraps google maps. When the map is clicked, I set the property, this works fine. However, when something else sets the property, I need to update the position on the map - how can I know the ''direction'' of a dependency property? For example:

OnLocationChanged(DependencyObject o, DependencyPropertyChangedEventArgs args)
{
// if its been set by the click, the map''s up to date

// if its been set otherwise, update the map
UpdateMapPosition(args.NewValue);
}



在此先谢谢!!



Thanks in advance!!

推荐答案

是不是只要位置发生更改,您是否都会更新地图?

然后在更新中,您只需要检查一下是否已将其设置为正确的位置即可.如果是这样,请纾困.如果不是,请更新地图.

您在这里要做的就是使两者保持同步.
Wouldn''t it be just the case that anytime the Location is changed, you would update the map?

Then inside the update, you''d just check to see if its already been set to the correct location. If so, bail out. If not, update the map.

All you are trying to do here is keep the two in sync.


这篇关于容易依赖的属性有疑问吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆