我在读取相册的时候每个图片都太大了!
我就想有没有可以生成缩略图的方式来显示这样可以节省手机内存
下面是代码 思路,不能跑起来
Image pici = new Image(); BitmapImage bi = new BitmapImage(); MemoryStream stream = new MemoryStream(byte[]); bi.SetSource(stream); pici.Source = bi; pici.Width = 1024; WriteableBitmap wb = new WriteableBitmap(pici, null); MemoryStream stream1 = new MemoryStream((int)pici.ActualHeight * (int)pici.ActualWidth * 4); wb.SaveJpeg(stream1, (int)(pici.ActualWidth), (int)(pici.ActualHeight), 0, 100); stream1.Seek(0, 0); bi.SetSource(stream1); stream = null; pici = null; wb = null;
但是发现处理后手机内存占用更大了,无奈没有采用,不知道有什么好的方法!
Windows Phone 7.0 2010年10月11日发布,它将微软旗下的Xbox LIVE游戏、Zune音乐和Bing等产品整合至手机中, Metro风格界面!(Windows Phone OS 7.0)
Windows Phone7.5 2011年9月27日发布 开始支持中文(Windows Phone OS 7.1)
|
Windows Phone 发行版本 |
操作系统版本 |
|
|
Windows Phone 7 |
Windows Phone OS 7.0 |
|
|
Windows Phone 7.5 |
Windows Phone OS 7.1 |
|
|
注意: |
||
|
Windows Phone 7.5 手机是一款运行 Windows Phone OS 7.1 的 Windows Phone。 |
||
Mango系统或是Tango系统,统称Windows Phone 7.5系统( Windows Phone OS 7.1 )
Mango( 芒果 512内存设备)
Tango =Mango阉割+Mango本地化 亚太地区专用 可以支持256M内存设备
对比7.0的主要更新:
多任务处理
后台代理、后台文件传输、后台音乐(可以后台运行单有标准)
定期代理和资源密集型代码任何时候都不能使用超过 6 MB 的内存。音频代理限制为 15 MB。如果计划任务超过此内存上限,则立即终止。
节电模式下可能不运行。
一般设备最多允许6个后台代理应用运行
后台文件传输限制:
上传最大文件最大 5 MB
手机网络连接的最大下载大小20 M
Wi-Fi 而没有外部电源的最大下载大小100 MB
Windows Phone 7.5 手机中的 GPU 速度更快
执行模型现在支持快速应用程序切换
Windows Phone OS 7.1 支持后台代理 -添加了对后台代理或任务的支持
WebBrowser 控件进行了主要更新
标准硬件
- 一组常用的硬件控件和按键,其中包括“开始”、“搜索”和“返回”按键。
- WVGA (800 x 480) 格式显示屏,
- 电容式多点(4 点)触摸屏。
- 支持使用手机网络和 Wi-Fi 进行数据连接。
- 256 MB(或更大)的 RAM 以及 8 GB(或更大)的闪存。
- A-GPS
- 加速度计
可选硬件
- 罗盘
- 陀螺仪
- 主相机
- 正面相机
Windows Phone 采取比iOS宽松比Android 规范的做法
Windows Phone7启动器与选择器
WIndowsPhone执行模型决定了 每个应用程序只能在自己的沙盒里运行
启动器和选择器为应用程序提供了间接访问这些功能的方法
启动器和选择器运行时操作系统可能会终止当前的应用程序
启动器:启动一个内置的程序给用户使用,不会返回任何的数据给调用的程序,例如搜索任务、电子邮件、在社交网络上共享链接、在浏览器中打开特定网站,等等。
选择器:启动一个内置的程序给用户使用, 返回一些数据给调用的程序,当用户完成操作时,程序会被重新激活,并接受到返回的数据,如选择联系人电子邮件地址、选择手机中的照片,以及保存新的铃声。
生命周期:

开发环境:
使用 Silverlight、XNA Framework 和 Windows Phone SDK 7.1 开发应用程序和游戏
语言支持:C#和VB 不支持(只有OEM 可以使用native code,其它公司使用不能通过市场审核)
开放工具:Visual Studio 2010+Blend
操作系统: WINXP 以上(不含xp)
定位:
只能使用手机的定位接口。
APP HUB:
开发者APP提交注册地址http://create.msdn.com
企业、个人都是99美元/年 解锁3个设备,每个设备10个应用,企业版需要解锁超过3个设备需要申请。
应用提交商场需要符合规范。
其它:



|
帧速率计数器 |
说明 |
|---|---|
|
构图(呈现)线程帧速率 (FPS) |
更新屏幕的速率。 |
|
用户界面线程帧速率 (FPS) |
运行 UI 线程的速率。 |
|
纹理内存使用量 |
应用程序中正在使用的纹理的视频内存和系统内存副本。 |
|
图面计数器 |
传递至 GPU 进行处理的显式图面的数量。 |
|
中间图面计数器 |
由缓存图面生成的隐式图面的数量。 |
|
屏幕填充速率计数器 |
以屏幕为单位每帧绘制的像素数量。值 1 表示 480 x 800 像素。 |
更多开发信息可以参考:
http://msdn.microsoft.com/zh-cn/library/ff637516(v=vs.92)
关于 WP8 的传闻:(微软官方没有证实或发布过的消息)
WIndows Phone 8是Windows Phone系统的下一个版本,也是目前Windows Phone的第三个大型版本。它是Windows Phone7.5(mango)更新后的下一个大型更新。(Tango只是Mango的小型更新,改变不大,不过让更多的终端产品能够运行)
WIndows Phone系列自诞生以来,经历了Nodo,Mango更新,今年迎来Tango更新,接下来就进入下一个重大版本更新即Apollo, Apollo是Windows Phone 8系统的第一个版本,也是第一个支持双核CPU的WP版本,宣布Windows Phone进入双核时代。
支持分辨率更高的屏幕,支持可移动MicroSD存储卡
NFC支持
Windows Phone 8在UI设计上将与Windows 8有很多相同点
内核将于Windows 8内核保持相同
Apollo支持Native Code
128位BitLocker本地磁盘加密
举例实现以下事件:
/// <summary>
/// 弹起后鼠标位置
/// </summary>
private MouseButtonEventArgs _mouseUpMouseButtonEventArgs;
/// <summary>
/// 单击鼠标左键时触发该事件
/// </summary>
public event EventHandler<MouseEventArgs> Mouse_Click;
/// <summary>
/// 单击鼠标右键事件
/// </summary>
public event EventHandler<MouseEventArgs> Mouse_Right_Click;
/// <summary>
/// 双击鼠标左键时触发该事件。
/// </summary>
public event EventHandler<MouseEventArgs> Mouse_Double_Click;
/// <summary>
/// 鼠标拖拽时触发该事件
/// </summary>
public event EventHandler<MouseEventArgs> Mouse_Drag_Start;
/// <summary>
/// 鼠标拖拽过程中触发该事件
/// </summary>
public event EventHandler<MouseEventArgs> Mouse_Dragging;
/// <summary>
/// 鼠标拖拽结束时触发该事件
/// </summary>
public event EventHandler<MouseEventArgs> Mouse_Drag_End;
具体实现如下:
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
namespace MapEngine.Events
{
/// <summary>
/// FrameworkElement相关事件
/// </summary>
public class FrameworkElementEvents
{
/// <summary>
/// 事件注册的容器
/// </summary>
private readonly FrameworkElement _frameworkElement;
/// <summary>
/// 鼠标是否在容器上
/// </summary>
private bool _isMouseOver;
/// <summary>
/// 是否激活事件
/// </summary>
private bool IsActive { get; set; }
/// <summary>
/// 最后点击的位置时间戳
/// </summary>
private DateTime _lastClick;
/// <summary>
/// 是否点击
/// </summary>
private bool _isMouseDown;
/// <summary>
/// 是否拖拽
/// </summary>
private bool _isMouseDrag;
/// <summary>
/// 鼠标双击速度间隔
/// </summary>
private const double MouseDoubleClickSpeed = 3000000;
private const double MouseDragDelay = 2000000.0;
/// <summary>
/// 单击速度
/// </summary>
private const double MouseClickSpeed = 2000000.0;
/// <summary>
/// 点击偏移量
/// </summary>
private const double MouseClickOffsetX = 10E-7;
/// <summary>
/// 点击偏移量
/// </summary>
private const double MouseClickOffsetY = 10E-7;
/// <summary>
/// 拖拽偏移量
/// </summary>
private const double MouseDragOffsetX = 10E-1;
/// <summary>
/// 拖拽偏移量
/// </summary>
private const double MouseDragOffsetY = 10E-1;
private Storyboard _storyboardOnFrame;
/// <summary>
/// 最后点击的位置
/// </summary>
private Point _lastClickPos;
/// <summary>
/// 单击后是否悬停等待下一个动作
/// </summary>
private bool _pendingClick = false;
/// <summary>
/// 是否正在拖拽
/// </summary>
private bool _dragging = false;
/// <summary>
/// 弹起后鼠标位置
/// </summary>
private MouseButtonEventArgs _mouseUpMouseButtonEventArgs;
/// <summary>
/// 单击鼠标左键时触发该事件
/// </summary>
public event EventHandler<MouseEventArgs> Mouse_Click;
/// <summary>
/// 单击鼠标右键事件
/// </summary>
public event EventHandler<MouseEventArgs> Mouse_Right_Click;
/// <summary>
/// 双击鼠标左键时触发该事件。
/// </summary>
public event EventHandler<MouseEventArgs> Mouse_Double_Click;
/// <summary>
/// 鼠标拖拽时触发该事件
/// </summary>
public event EventHandler<MouseEventArgs> Mouse_Drag_Start;
/// <summary>
/// 鼠标拖拽过程中触发该事件
/// </summary>
public event EventHandler<MouseEventArgs> Mouse_Dragging;
/// <summary>
/// 鼠标拖拽结束时触发该事件
/// </summary>
public event EventHandler<MouseEventArgs> Mouse_Drag_End;
/// <summary>
/// 触发鼠标拖拽事件
/// </summary>
/// <param name="args"></param>
private void FireMouse_Dragging(MouseEventArgs args)
{
if (this.Mouse_Dragging != null)
{
Mouse_Dragging(_frameworkElement, args);
}
} /// <summary>
/// 触发双击鼠标左键事件
/// </summary>
/// <param name="args"></param>
private void FireMouse_Double_Click(MouseEventArgs args)
{
if (this.Mouse_Double_Click != null)
{
Mouse_Double_Click(_frameworkElement, args);
}
}
/// <summary>
/// 触发开始拖拽事件
/// </summary>
/// <param name="args"></param>
private void FireMouseDragStart(MouseEventArgs args)
{
if (this.Mouse_Drag_Start != null)
{
Mouse_Drag_Start(_frameworkElement, args);
}
}
/// <summary>
/// 触发单击鼠标右键事件
/// </summary>
/// <param name="args"></param>
private void FireMouse_Right_Click(MouseEventArgs args)
{
if (this.Mouse_Right_Click != null)
{
Mouse_Right_Click(_frameworkElement, args);
}
}
/// <summary>
/// 触发单击鼠标左键事件
/// </summary>
/// <param name="args"></param>
private void FireMouse_Click(MouseEventArgs args)
{
if (this.Mouse_Click != null)
{
Mouse_Click(_frameworkElement, args);
}
}
/// <summary>
/// 触发鼠标拖拽结束事件
/// </summary>
/// <param name="args"></param>
private void FireMouse_Drag_End(MouseEventArgs args)
{
if (this.Mouse_Drag_End != null)
{
Mouse_Drag_End(_frameworkElement, args);
}
}
///// <summary>
///// 是否允许鼠标滚轮
///// </summary>
//public bool IsWheelEnabled { get; set; }
/// <summary>
/// 构造函数,需要地图实例或 容器
/// </summary>
public FrameworkElementEvents(FrameworkElement fe)
{
_frameworkElement = fe;
IsActive = false;
}
/// <summary>
/// 激活事件
/// </summary>
public void Active()
{
if (!IsActive)
{
if (_storyboardOnFrame == null)
{
this._storyboardOnFrame = new Storyboard();
}
this._storyboardOnFrame.Duration += new Duration(new TimeSpan(0, 0, 0, 0, 0));
this._storyboardOnFrame.Completed += new EventHandler(this.StoryboardOnFrame_Completed);
_frameworkElement.MouseLeftButtonDown += new MouseButtonEventHandler(_Map_MouseLeftButtonDown);
_frameworkElement.MouseLeftButtonUp += new MouseButtonEventHandler(_Map_MouseLeftButtonUp);
_frameworkElement.MouseMove += new MouseEventHandler(_Map_MouseMove);
_frameworkElement.MouseEnter += new MouseEventHandler(_MouseEnter);
_frameworkElement.MouseLeave += new MouseEventHandler(_MouseLeave);
IsActive = true;
}
}
/// <summary>
/// 注销事件
/// </summary>
public void DeActive()
{
if (IsActive)
{
if (_storyboardOnFrame != null)
{
this._storyboardOnFrame.Stop();
_storyboardOnFrame = null;
}
_frameworkElement.MouseLeftButtonDown -= new MouseButtonEventHandler(_Map_MouseLeftButtonDown);
_frameworkElement.MouseLeftButtonUp -= new MouseButtonEventHandler(_Map_MouseLeftButtonUp);
_frameworkElement.MouseMove -= new MouseEventHandler(_Map_MouseMove);
_frameworkElement.MouseEnter -= new MouseEventHandler(_MouseEnter);
_frameworkElement.MouseLeave -= new MouseEventHandler(_MouseLeave);
IsActive = false;
}
}
#region 鼠标事件
/// <summary>
/// 鼠标左键
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void _Map_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (!e.Handled)
{
_frameworkElement.CaptureMouse();
_isMouseDown = true;//鼠标按下
this._pendingClick = false;
if ((DateTime.Now.Ticks - _lastClick.Ticks) < MouseDoubleClickSpeed)
{
this._pendingClick = false;
if (Math.Abs(e.GetPosition(_frameworkElement).X - _lastClickPos.X) < 5 && Math.Abs(e.GetPosition(_frameworkElement).Y - _lastClickPos.Y) < 5)
{
Point viewportPoint = e.GetPosition(_frameworkElement);
FireMouse_Double_Click(e);
}
this._lastClick = DateTime.MinValue;
}
else
{
this._lastClick = DateTime.Now;
}
_lastClickPos = e.GetPosition(_frameworkElement);
this._storyboardOnFrame.Begin();
}
}
/// <summary>
/// 鼠标移动
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void _Map_MouseMove(object sender, MouseEventArgs e)
{
RaiseIfMouseDrag(e);
_isMouseDrag = true;
}
/// <summary>
/// 鼠标左键抬起
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
void _Map_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
_frameworkElement.ReleaseMouseCapture();
_mouseUpMouseButtonEventArgs = e;
TimeSpan span = (TimeSpan)(DateTime.Now - this._lastClick);
if (span.TotalSeconds < 10.0 && !this._dragging)
{
this._pendingClick = true;
this._storyboardOnFrame.Begin();
}
if (_isMouseDown && _isMouseDrag)
{
if (this._dragging)
{
Point viewportPoint = e.GetPosition(_frameworkElement);
FireMouse_Drag_End(e);
}
_dragging = false;
}
_isMouseDown = false;
_isMouseDrag = false;
}
/// <summary>
/// 定时检测鼠标事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void StoryboardOnFrame_Completed(object sender, EventArgs e)
{
this.Update();
}
/// <summary>
/// 更新鼠标动作
/// </summary>
private void Update()
{
DateTime now = DateTime.Now;
if (this._pendingClick)
{
TimeSpan span = (TimeSpan)(now - this._lastClick);
if (span.TotalSeconds >= 0.3 && _mouseUpMouseButtonEventArgs != null)
{
this._pendingClick = false;
this.RaiseIfMouseClick(_mouseUpMouseButtonEventArgs);
}
this._storyboardOnFrame.Begin();
}
}
/// <summary>
/// 鼠标点击事件
/// </summary>
/// <param name="map"></param>
/// <param name="args"></param>
private void RaiseIfMouseClick(MouseButtonEventArgs args)
{
bool offsetX = Math.Abs(args.GetPosition(_frameworkElement).X - _lastClickPos.X) < MouseClickOffsetX;
bool offsetY = Math.Abs(args.GetPosition(_frameworkElement).Y - _lastClickPos.Y) < MouseClickOffsetY; ;
if (offsetX && offsetY)
{
Point viewportPoint = args.GetPosition(_frameworkElement);
FireMouse_Click(args);
}
}
/// <summary>
/// 地图拖拽事件
/// </summary>
/// <param name="map"></param>
/// <param name="args"></param>
private void RaiseIfMouseDrag(MouseEventArgs args)
{
if (_isMouseDown)
{
if (_lastClick.Ticks != 0)
{
double offsetX = args.GetPosition(_frameworkElement).X - _lastClickPos.X;
double offsetY = args.GetPosition(_frameworkElement).Y - _lastClickPos.Y;
if (_isMouseDown && Math.Abs(offsetX) > MouseDragOffsetX && Math.Abs(offsetY) > MouseDragOffsetY)
{
Point viewportPoint = args.GetPosition(_frameworkElement);
if (!_dragging)
{
FireMouseDragStart(args);
}
else
{
FireMouse_Dragging(args);
}
_dragging = true;
}
}
}
}
#endregion
/// <summary>
/// 鼠标移入
/// </summary>
/// <param name="map"></param>
/// <param name="args"></param>
private void _MouseEnter(object map, MouseEventArgs args)
{
_isMouseOver = true;
}
/// <summary>
/// 鼠标移出
/// </summary>
/// <param name="map"></param>
/// <param name="args"></param>
private void _MouseLeave(object map, MouseEventArgs args)
{
_isMouseDown = false;
_frameworkElement.ReleaseMouseCapture();
}
}
}
调用方式:
Grid grid = new Grid();
FrameworkElementEvents fl = new FrameworkElementEvents(grid);
fl.Active();
fl.Mouse_Click += new EventHandler<MouseEventArgs>(fl_Mouse_Click);
void fl_Mouse_Click(object sender, MouseEventArgs e)
{
MessageBox.Show(sender+"单击实现了!");
}
更多事件可以自己封装!
一、 为什么要在WIN8上开发
微软给出了下图,为用户数大概的比例为 5:2.5:1.5 呵呵!~

二、在Windows 8当中开发 用什么语言开发 Metro 风格应用(Metro style app)
- 如果你了解 web 开发技术,可以使用 HTML5、层叠样式表、级别 3 (CSS3) 以及 JavaScript 来开发 Metro 风格应用。
- 如果已开发了 Windows Presentation Foundation 或 Silverlight 应用程序,可以使用 XAML,借助 C++、C# 或 Microsoft Visual Basic 中的代码开发 Metro 风格应用。
- 如果你了解 Microsoft DirectX,可以使用本机 C++ 和 HLSL 开发 Metro 风格 DirectX 游戏,从而全面利用图形硬件的优势。
注意: 只有 Windows 8 支持 Metro 风格应用开发。不能在 Windows 7 或 Windows Server 8 Beta 上开发 Metro 风格应用。
Windows 8当中分Metro 风格应用 与 桌面应用 微软所说的兼容win7下的应用都是桌面应用! 看下面的图就很好理解了!

三、开发设计工具
开发工具Microsoft Visual Studio 11 Express Beta for Windows 8 (只能安装在WIN8上)
设计工具 Microsoft Expression Blend
设计应用程序的用户体验原则请参考:http://msdn.microsoft.com/zh-cn/library/windows/apps/hh779072.aspx
Metro style app principles
有以下特点:
1、快速和流畅
2、支持多种状态。支持全屏显示,小窗口状态等
3、Support for the right contracts.
Contracts
它是开发模型的一个新方向,它为各种独立开发的应用提供了相互通信的基础它可以额外提供一些相当有用的服务,比如搜索和共享。
搜索 让用户从系统中的任何位置(包括其他应用)在你的整个应用内容中执行快速搜索。
共享 让你的用户将你的应用的内容通过其他应用与其他人共享,并从其他人员和应用那里接收可共享的内容。只需从屏幕右侧向内滑动呼出Charm bar,点击共享按钮,接着会打开一个共享目标列表,它们可以是Facebook、Twitter以及其他社交网络,当人国内是新浪微博、人人等平台,当然遵守contracts也可以开发出分享平台。
4、Live Title(活动瓷贴)
5、云服务(邮件、日历、联系人以及照片)
四、各种语言开发下如何保护知识产权?
利用各个语言自己的混淆工具,如JS就用JS混淆工具,其它语言同样!
五、Windows Store makes
注册费用 开发者帐户 个人49美元 公司99美元 /年
分成比例为 7:3 (微软拿三)
如果应用营收超过25000美金分成比例为 8:2
目前国内还没有开发注册,目前官方应用商店是邀请制!
购买应用将允许第三方支付!
六、更容易的异步开发方式(C#示例)
方法里的 async 关键字声明为异步方法 void 或返回Task<T>
private async Task<FeedData> GetFeedAsync(string feedUriString)
{
...
}
用关键字await 获得异步方法的返回
SyndicationFeed feed = await client.RetrieveFeedAsync(feedUri);
七、其它
在WIN8里 可以在页面里连接到 Windows Store 安装相应的程序
例如:人人已经走在前列!在Windows 8下的Metro IE中访问人人网站,只要你点击地址栏上的人人网图标,就可以快速的启动Renren HD应用程序。如果还没有安装软件也没有关系,它会引导你去Windows Store中下载安装
首先去 http://q.weibo.com/457681/file/13470763 下载 开发包和示例
以前的示例可以看一下!
我们来新增一个例子!
新增一个
AddMarkers.xaml 先把地图初始化方法见示例里的DisplayMap.xaml
在MainPage.xaml 增加 多点添加 连接到 AddMarkers.xaml
好第一步AddMarkers.xaml.cs 里添加一个点
代码如下
public partial class AddMarkers : PhoneApplicationPage
{
MMarker maker1;
public AddMarkers()
{
InitializeComponent();
InitAddOverlays();
}
public void InitAddOverlays()
{
if (null==maker1)
{
maker1 = new MMarker(new MLngLat(116.3,36.5));//初始化点
map.Children.Add(maker1);//添加点
map.Center = maker1.LngLat;//把改点设为地图中心点
}
}
}
}
点就添加好了还挺容易吧!
好现在让我们添加一个TIP,就是标注点的信息
MTip tip = new MTip();
tip.Title = "这是一个点!";
tip.ContentText = "这里是点的内容!";
maker1.TipFrameworkElement = tip;//把tip信息与点绑定
点击点就能看到如下效果!
效果如下

我们看到MMarker 有个属性
TipFrameworkElement
为什么叫FrameworkElement是这样,MMarker.TipFrameworkElement 接受的值为FrameworkElement类型,也就是说,
你可以自己定义一个Grid 然后覆盖物MMarker显示该Grid 并随着地图移动而移动!好了我们动手吧!
先设计一个Grid 我就懒得弄了,把 吾得地图 的Grid 拿了过来了,不怎么好看,您自己设计吧,我不是很懂设计,呵呵
添加到XAML
<Grid x:Name="BusOrCar" Visibility="Collapsed" Background="{StaticResource PhoneAccentBrush}" Height="150" Width="250" Opacity="0.8" >
<Grid >
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<Grid Background="White" Grid.Row="0">
<TextBlock Text="根据选择点查询:" />
<Image Source="/ContentImage/close.png" Stretch="None" HorizontalAlignment="Right" Tap="Image_Tap"></Image>
</Grid>
<TextBlock Text="起点:" Foreground="White" Grid.Row="1" Margin="10,0,181,0" VerticalAlignment="Center"></TextBlock>
<TextBlock Text="终点:" Foreground="White" Grid.Row="2" Margin="10,0" VerticalAlignment="Center"></TextBlock>
<TextBlock Text="" Foreground="White" x:Name="start" Grid.Row="1" Margin="70,0,-60,0" Width="240"></TextBlock>
<TextBlock Text="" Foreground="White" x:Name="end" Grid.Row="2" Margin="70,0,-60,0" Width="240"></TextBlock>
<Button Content="查公交" Style="{StaticResource ButtonStyle1}" Margin="-120,-5,0,0" Width="130" Height="70" Grid.Row="3" Click="Bus_Button_Click" />
<Button Content="查驾车" Style="{StaticResource ButtonStyle1}" Margin="120,-5,0,0" Width="130" Height="70" Grid.Row="3" Click="CarButton_Click" />
</Grid>
</Grid>
cs里为
maker1.TipFrameworkElement = BusOrCar;
void Image_Tap(object obj,EventArgs args)
{
BusOrCar.Visibility = System.Windows.Visibility.Collapsed;
}
效果如下,Grid 可以与Marker 移动了

到这里就基本上完成了,多点你就自己写集合添加吧,不难!
这里还有一个高级应用,就是添加在地图里的覆盖物有2个附件属性,所有的
FrameworkElement都可以附加 MapLayer.AnchorProperty(锚点) 属性和 MapLayer.LngLatProperty(经纬度)
这样添加在地图里的覆盖物就可以定位到一个位置!
好我们在来一个例子:执行一下方法就可以了! 这回这个Grid 不依赖任何覆盖物,您如果还需要依赖MMarker 你可以自己写一个类继承
MMarker 然后有个属性为UserControl 或者ContentControl 做为自定义Tip
void AddGrid()
{
BusOrCar.SetValue(MapLayer.AnchorProperty, new Point(0.5, 1));//附加属性以Grid的中下部为锚点
BusOrCar.SetValue(MapLayer.LngLatProperty, new MLngLat(116.5, 39.5));//附加属性以Grid的地图位置
map.Children.Add(BusOrCar);//添加到地图
BusOrCar.Visibility = System.Windows.Visibility.Visible;//xaml里隐藏了,记得显示
}
其实
BusOrCar 这个 Grid 我偷懒了,按理应该自己写一个UserControl 或者ContentControl 更利于我们复用,道理都是一样的,具体怎么发挥就要看您的灵感了!
示例 和 SDK 都打包放到这里了 http://q.weibo.com/457681/file/49366115 欢迎下载!
由于 高德的WP7-SDK 还是测试版本所以..... 有问题反馈不要骂娘,好了,还有其它的可以微博和我联系!~

