mysqlmysql 读写分离离和用Redis做缓存,这两种方案有什么异同

Xamarin(3)
解决方案(2)
第三方原生Api的绑定(Binding)应该是Xamarin使用上最头痛的问题,
Thinkpower有鉴于此,将为大家制作免费而且开源的绑定,
前期重点在于提供替代Google服务的绑定(例如地图、推播、支付等),
本文延续第三篇的案例,演示引用Nuget高德地图绑定(预览版)到Xamarin.Forms中使用
演示版: Xamarin.Forms.1.4.1.6349
演示目标: 显示高德地图
先熟悉一下在一般Android项目中如何使用Com.Amap.Api.Maps2d.MapView (参照高德API官网),
步骤如下 1.新建Blank App (Android)专案
2. 在项目设定页中,Compile using Android version的选项默认Use Lastest Platform是不可以用的,
否则之后安装Nuget组件时会出现Bug 25534错误(/show_bug.cgi?id=25534
本文使用Xamarin.VisualStudio_3.9.547.msi),
必须指定为你想编译的Android版本
3.在Nuget组件安装先选Include Prerelease再搜寻thinkpower可找到
Thinkpower.BindingANDROID.AMap_Map
4.比对高德API官网翻成C#,apikey可使用MetaData卷标属性设值
下篇将演示如何在Xamarin.Forms中使用!
作者:Eco Hsieh&
/xamarin/cn/Article_20.aspx?idx=20#xamarin_top
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:4109次
排名:千里之外
(1)(2)(2)(1)(2)经检测你所在的网络可能存在爬虫,因资源限制,我们只能拒绝你的请求。
如果你是推酷的用户,可以以继续访问使用。
如有疑问,可将IP信息发送到
请求解封。xamarin(28)
【广告】168vpn 翻墙神器。多多支持
Gesture Recognizers with Xamarin.Forms
09 JANUARY 2015
iOS and Android apps both provide a way to wire up a UI control to listen for specific touch events. These events are called gestures. Typically, we would use this to listen for a tap (click) gesture, or maybe a swipe or fling gesture.
In a native Xamarin.iOS or Xamarin.Android app, wiring up these events is fairly straight forward. As of this writing though (July, 2014),&. Just because all of the gesture recognizers aren't wrapped for Xamarin.Forms does not mean that we can not use them though. By using&, we are able to get access to the native controls and wire up our gesture recognizer just as we would in a native Xamarin app.
I have created a sample app in my&&to demonstrate how we can use the simplicity of Xamarin.Forms and still have the power
of built in gesture recognizers.
Sample App
We'll start with a new Xamarin.Forms app. This can be a Shared Project or a Portable project (the sample app is a Shared Project). For this sample, we're going to wire up a&Label&control to listen for the touch
To be able to use a custom renderer, we'll need to subclass&Label&in our shared code.
using Xamarin.Forms;
namespace XamarinFormsGestureRecognizers
public class FancyLabel : Label {}
In our&App.cs&we'll set the Content of our&Page&to a new&FancyLabel. Since the&TapGestureRecognizer&is already built in to Xamarin.Forms,
we'll wire that one up here in our shared code.
using Xamarin.Forms;
using System;
namespace XamarinFormsGestureRecognizers
public static class App
public static Page GetMainPage ()
var fancyLabel = new FancyLabel {
Text = &Hello, Forms!&,
VerticalOptions = LayoutOptions.CenterAndExpand,
HorizontalOptions = LayoutOptions.CenterAndExpand,
var tapGestureRecognizer = new TapGestureRecognizer ();
tapGestureRecognizer.Tapped += (sender, e) =& Console.WriteLine (&Tapped&);
fancyLabel.GestureRecognizers.Add (tapGestureRecognizer);
return new ContentPage {
Content = fancyLabel
Now we need to implement our custom renderers for each platform.
We'll add a new file named&FancyIosLabelRenderer.cs&to the iOS project and add a class derived from Xamarin.Forms'&LabelRenderer.
using Xamarin.Forms;
using Xamarin.Forms.Platform.iOS;
using MonoTouch.UIKit;
using System;
using XamarinFormsGestureRecognizers;
using XamarinFormsGestureRecognizers.iOS;
namespace XamarinFormsGestureRecognizers.iOS
public class FancyIosLabelRenderer : LabelRenderer
protected override void OnElementChanged (ElementChangedEventArgs&Label& e)
base.OnElementChanged (e);
The renderer class itself is a view that wraps the native control. While we could wire up the recognizer to the control itself, it's better to simply wire it up to the renderer's view. Since the renderers can be reused, we also need to be sure to
only create the gesture recognizers if the OldElement is null (when we're not reusing the control).
public class FancyIosLabelRenderer : LabelRenderer
UILongPressGestureRecognizer longPressGestureRecognizer;
UIPinchGestureRecognizer pinchGestureRecognizer;
UIPanGestureRecognizer panGestureRecognizer;
UISwipeGestureRecognizer swipeGestureRecognizer;
UIRotationGestureRecognizer rotationGestureRecognizer;
protected override void OnElementChanged (ElementChangedEventArgs&Label& e)
base.OnElementChanged (e);
longPressGestureRecognizer = new UILongPressGestureRecognizer (() =& Console.WriteLine (&Long Press&));
pinchGestureRecognizer = new UIPinchGestureRecognizer (() =& Console.WriteLine (&Pinch&));
panGestureRecognizer = new UIPanGestureRecognizer (() =& Console.WriteLine (&Pan&));
swipeGestureRecognizer = new UISwipeGestureRecognizer (() =& Console.WriteLine (&Swipe&));
rotationGestureRecognizer = new UIRotationGestureRecognizer (() =& Console.WriteLine (&Rotation&));
if (e.NewElement == null) {
if (longPressGestureRecognizer != null) {
this.RemoveGestureRecognizer (longPressGestureRecognizer);
if (pinchGestureRecognizer != null) {
this.RemoveGestureRecognizer (pinchGestureRecognizer);
if (panGestureRecognizer != null) {
this.RemoveGestureRecognizer (panGestureRecognizer);
if (swipeGestureRecognizer != null) {
this.RemoveGestureRecognizer (swipeGestureRecognizer);
if (rotationGestureRecognizer != null) {
this.RemoveGestureRecognizer (rotationGestureRecognizer);
if (e.OldElement == null) {
this.AddGestureRecognizer (longPressGestureRecognizer);
this.AddGestureRecognizer (pinchGestureRecognizer);
this.AddGestureRecognizer (panGestureRecognizer);
this.AddGestureRecognizer (swipeGestureRecognizer);
this.AddGestureRecognizer (rotationGestureRecognizer);
Lastly, we need to be sure that we wire up the custom renderer to look for instances of the&FancyLabel&class.
[assembly: ExportRenderer (typeof(FancyLabel), typeof(FancyIosLabelRenderer))]
Using the gesture recognizers in Android will be similar, but with a bit more work.&&explains
how to use a&GestureDetector&in an Android app, which is what we'll do here.
Once again, we'll add a new file called&FancyAndroidLabelRenderer.cs&to hold our custom renderer.&
using Xamarin.Forms.Platform.Android;
using Xamarin.Forms;
using XamarinFormsGestureRecognizers;
using XamarinFormsGestureRecognizers.Droid;
using Android.Views;
namespace XamarinFormsGestureRecognizers.Droid
public class FancyAndroidLabelRenderer : LabelRenderer
public FancyAndroidLabelRenderer ()
protected override void OnElementChanged (ElementChangedEventArgs&Label& e)
base.OnElementChanged (e);
We'll also add a class named&FancyGestureListener.cs&and we'll add gesture listener. Here we'll subclass the built in&SimpleOnGestureListener&to provide most of the functionality.
using Android.Views;
using System;
namespace XamarinFormsGestureRecognizers.Droid
public class FancyGestureListener : GestureDetector.SimpleOnGestureListener
public override void OnLongPress (MotionEvent e)
Console.WriteLine (&OnLongPress&);
base.OnLongPress (e);
public override bool OnDoubleTap (MotionEvent e)
Console.WriteLine (&OnDoubleTap&);
return base.OnDoubleTap (e);
public override bool OnDoubleTapEvent (MotionEvent e)
Console.WriteLine (&OnDoubleTapEvent&);
return base.OnDoubleTapEvent (e);
public override bool OnSingleTapUp (MotionEvent e)
Console.WriteLine (&OnSingleTapUp&);
return base.OnSingleTapUp (e);
public override bool OnDown (MotionEvent e)
Console.WriteLine (&OnDown&);
return base.OnDown (e);
public override bool OnFling (MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
Console.WriteLine (&OnFling&);
return base.OnFling (e1, e2, velocityX, velocityY);
public override bool OnScroll (MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)
Console.WriteLine (&OnScroll&);
return base.OnScroll (e1, e2, distanceX, distanceY);
public override void OnShowPress (MotionEvent e)
Console.WriteLine (&OnShowPress&);
base.OnShowPress (e);
public override bool OnSingleTapConfirmed (MotionEvent e)
Console.WriteLine (&OnSingleTapConfirmed&);
return base.OnSingleTapConfirmed (e);
Then, we need to wire up this listener to our renderer, and include the&ExportRenderer&attribute.
using Xamarin.Forms.Platform.Android;
using Xamarin.Forms;
using XamarinFormsGestureRecognizers;
using XamarinFormsGestureRecognizers.Droid;
using Android.Views;
[assembly: ExportRenderer (typeof(FancyLabel), typeof(FancyAndroidLabelRenderer))]
namespace XamarinFormsGestureRecognizers.Droid
public class FancyAndroidLabelRenderer : LabelRenderer
private readonly FancyGestureListener _listener;
private readonly GestureDetector _detector;
public FancyAndroidLabelRenderer ()
_listener = new FancyGestureListener ();
_detector = new GestureDetector (_listener);
protected override void OnElementChanged (ElementChangedEventArgs&Label& e)
base.OnElementChanged (e);
if (e.NewElement == null) {
if (this.GenericMotion != null) {
this.GenericMotion -= HandleGenericMotion;
if (this.Touch != null) {
this.Touch -= HandleTouch;
if (e.OldElement == null) {
this.GenericMotion += HandleGenericMotion;
this.Touch += HandleTouch;
void HandleTouch (object sender, TouchEventArgs e)
_detector.OnTouchEvent (e.Event);
void HandleGenericMotion (object sender, GenericMotionEventArgs e)
_detector.OnTouchEvent (e.Event);
Checkout the sample app on my&&to get started with Xamarin.Forms and gestures.
Read&&by this author.
Share this post
&&&(C) 2015Proudly published with&
参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:20080次
排名:千里之外
原创:30篇
转载:22篇
(6)(2)(4)(3)(3)(2)(21)(2)(1)(1)(3)(4)7550人阅读
跨平台(9)
&&&&&& 由于HTML5规范于2014年10月终于定稿,公司.net开发人员较少,国内外已有了较为成熟的UI框架、手机软件硬件的快速发展等等原因,所以我就不打算再使用Xamarin了,而是采用HTML5+CSS3+Javascript的方式来进行跨平台的开发。之前在探索Xamarin中积累了一些小经验也同时分享给大家,希望能给大家带来帮助。
1.TabbedPage中嵌入NavigationPage,NavigationPage中的Root的title是Actionbar的标题,NavigationPage的Title是Tab的标题
2.暂时写的ExtendedNavigationPage 中的样式由于bug原因,在和TabbedPage一起使用时不起作用。
3.在Android中自定义样式的话,还是在样式文件中定义
4.启动Activity上注解Label会改变应用的名称,只需要删除掉Label标签即可显示在项目属性中设置的应用名称。
5.9patch文件有问题,用android自带的工具即可。
6.像素转dp:Resolver.Resolve&IDevice&().Display.Width / (Resolver.Resolve&IDevice&().Display.Ydpi / 160)
7.Grid 默认行、列之间是有间距的 &通过设置 RowSpacing=&0&
Error 5 The 'ProductID' attribute is invalid - The value '75b13d4c-4f0c-4b78-9d7f-8d09b3d5d4d0' is invalid according to its datatype ':ST_Guid'
- The Pattern constraint failed. THSFramework.WinPhone&
打开WinPhone项目下Properties中的WMAppManifest.xml 在ProductID的值上用大括号括起来 如: ProductID=&{75b13d4c-4f0c-4b78-9d7f-8d09b3d5d4d0}&
设置Actionbar样式:
var navigon = new NavigationPage(new WebViewPage());
navigon.BarBackgroundColor = Color.T
navigon.BarTextColor = Color.White


参考知识库
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
访问:524971次
积分:4013
积分:4013
排名:第6086名
原创:60篇
评论:200条
(1)(6)(1)(2)(4)(10)(1)(1)(2)(1)(1)(4)(1)(1)(1)(1)(1)(2)(1)(8)(4)(1)(10)(5)福利来了,Xamarin.Forms入门困扰与解决方式第一篇!解决方案 - Sql Server当前位置:& &&&福利来了,Xamarin.Forms入门困扰与解决方式第一篇福利来了,Xamarin.Forms入门困扰与解决方式第一篇!解决方案&&网友分享于:&&浏览:0次福利来了,Xamarin.Forms入门困扰与解决方式第一篇!Xamarin.Forms入门困扰与解决方式-第一篇
Xamarin.Forms虽然是朝着程式码共用极致的迈进,但是一些怪异的坑洞会打击开发者的使用意愿,本文将演示一个很常见的入门困扰与解决方式。
演示版本:&Xamarin.Forms.1.3.1.6294-pre1(支援Unified&API)
演示目标:&红框标识的控制项放在在ListView外面与里面(由分割线区分)的结果要一致
在Microsoft版的Xaml开发中,上下两块红框中的Button都是使用Command="{Binding&CmdAdd}"&来开发想做的命令,控制项不会因为所处位置不同而有用法的差别;但是在Xamarin版的Xaml开发中,下方ListView内的Button却使用Event的写法Clicked="OnClicked",明显的逻辑不一致!
这种设计上的混乱还会影响.cs,在事件处理的年代(WinForm、WebForm),习惯使用FindControlById之类的做法去取得书面上的值,但是Xaml是基于MVVM的,必须使用下列写法才能取得使用者正在操作的那一列物件。
在新版修正前,这种基础解法提供开发者绕过这个坑,享受Xamarin.Forms的优点。
附注其他解法
/discussion/29117/expose-listviews-itemtapped-event-as-icommand-via-attached-property
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&昕创(上海)软件科技有限公司
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&顾问Consultant:Eco------解决思路----------------------敢脚你发错地方了------解决思路----------------------你的精神是好的,但是发错地方了吧,------解决思路----------------------移动到&移动开发版块下面吧。&这边的人,基本上都不怎么懂。
12345678910
12345678910
12345678910 上一篇:下一篇:文章评论相关解决方案 1234567891011 Copyright & &&版权所有

我要回帖

更多关于 mysql 读写分离 的文章

 

随机推荐