English 中文(简体)
为Metro 应用程序动画 Bing 地图上的标记标记钉
原标题:Animating a marker pin on Bing Maps for Metro apps

我有一个Bing地图控制器,我想动画 地图上画的插针的位置。

Ideally I d want to write code like this:

// Image myPin = some Image on the map layer;

var sb = new Storyboard();
var duration = DurationHelper.FromTimeSpan(System.TimeSpan.FromMilliseconds(1000));
sb.Duration = duration;

LocationAnimation ani = new LocationAnimation();
ani.To = new Location(33.3, 11.1); // destination lat, lng
ani.Duration = duration;

sb.Children.Add(ani);
Storyboard.SetTarget(ani, myPin);
Storyboard.SetTargetProperty(ani, "MapLayer.Position");

Resources.Add("moveMyPin", sb);
sb.Begin();

当然,在框架中没有 LobtionAnimation 类。有几类类似的东西: PointAnimation >point 类型合作,而 DoubleAnimation 与单项 价值合作。

我假设我必须执行我的“Timeline -product class”课程,但我迄今发现的文件在这方面没有帮助,我不知道从何说起。

如何对没有动画课的财产动画?

<强> 更新 : 我<他们> 认为 我可以做类似的事情

// let aniX and aniY be two DoubleAnimation objects
StoryBoard.SetTargetProperty(aniX, "(MapLayer.Position).Latitude")
StoryBoard.SetTargetProperty(aniY, "(MapLayer.Position).Longitude")

但现在我又遇到另一个问题, 因为我看不到如何动画附着的房产, 并总是得到一个例外, 比如“ 无法解决目标属性( MapLayer. possition) 。 耐心等待指定对象 ” 。

所以我猜现在的问题是: 如何为附加属性指定属性路径?

< 坚固 > 进一步更新 < / 坚固 > : 我可能使用“ etTagetProperty” 错误的线索, 因为这会使一个 < em > 依赖动画 < / em > (见注释中的链接) 。 是否有更好的方法将一个标记针添加到协调点?

<强度> 更新3 < /强度 > : 正如Jared指出的,我可以尝试动画 < code> Render Transform ,或者利用过渡实现我的结果。我已经这样做了,但似乎不是我的解决办法。

  • Using RepositionThemeAnimation, it seems I have to give the new pixel position of the pin. This is problematic for a couple reasons: first, I know the lat/lng destination of the pin, but would have to work out the projection (as far as I can tell there is no public interface to work with projection). Secondly the projection itself can change as the map zooms/pans. The pixel destination at the time of the end of the animation could not be the same as the initial pixel destination. In my scenario it s a major problem as it s very likely the map is moving while the animation is occurring.
  • Using RepositionThemeTransition all the weird pixel/projection problems went away. It s the only way so far I was able to see the animation I expected. I just set the transition and set the new lat/lng position of the tag (via MapLayer.SetPosition). It has two major problems though. I can t set the duration (nor the easing functions) for the animation. And most importantly I can see no way to execute code when the pin gets to its final position.
问题回答

附加的属性可以动画,但您必须将其名称以括号附加。请参见以下示例:

http://www.charlespetzold.com/blog/2007/09/080231.html

然而,我认为这只能用来确定整个价值(位置)和可能不具有的子属性(纬度和经度)。

我想知道您能否提供更多关于您正在尝试做什么的信息。 这是临时动画吗? 也就是说, 您想要在入口或离开时使用动画针来动画吗? 如果您想在 Render Transform X 和 Y 上做动画的话。 您实际上不会改变动画针的位置, 但是您可以使用 Render Transform 来临时更改它被画的地方 。

更好的是,你也许可以逃脱 自由动画现在建在框架中。你甚至不需要一个故事板来使用这些动画, 你只要把它们放在像这样的元素上:

<Button Content="Transitioning Button">
     <Button.Transitions>
         <TransitionCollection> 
             <EntranceThemeTransition/>
         </TransitionCollection>
     </Button.Transitions>
</Button>

更多动画库的例子,甚至许多动画的视频预览,见:

http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh452703.aspx" rel=“nofollow'>http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh452703.aspx

好吧,伙计,你的问题与宾夕法尼亚地图无关。它与无法动画 ULESS 的依附属性有关。您指定了它们可以。这里是: < a href="http://blog.jerrynixon.com/2012/06/windows-8-animated-pie-sice.html" rel=“nofollow'>http://blog.jerrynixon.com/2012/06/windows-8-animed-pie-sice.html

与Charles网站的另一个答案中的链接尚未更新。





相关问题
How to bind a TabControl to an ObservableCollection in XAML

I have the following line of code in my code-behind class. TabControl.ItemsSource = ((MainWindowViewModel)DataContext).TabItemViewModels; I would like to move this to the XAML file. In brief, ...

Bind to ancestor of adorned element

Here is the case: <DataTemplate x:Key="ItemTemplate" DataType="local:RoutedCustomCommand"> <Button Command="{Binding}" Content="{Binding Text}" ...

FlowDocument Force a PageBreak (BreakPageBefore)

I m using C# to create a FlowDocument and fill it with data within a table. Example: FlowDocument flowDoc = new FlowDocument(); Table table1 = new Table(); flowDoc.Blocks.Add(table1); table1....

Editing a xaml icons or images

Is it possible to edit a xaml icons or images in the expression design or using other tools? Is it possible to import a xaml images (that e.g you have exported) in the expression designer for editing?...

WPF TreeView binding through XAML

So I have a class structure like this Store Owner Cashier List of Products Product Name Price List of Vendors Company Name Contact Name So there are 4 ...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签