Tag: xamarin.forms

如何获取服务器(不是网络服务器)的IP地址,而是在Xamarin.Forms中的wifi模块上创建的TCP服务器

我需要获取运行TCP服务器的Wi-Fi模块的IP地址。 应用程序将打开WiFi连接设置页面,以允许用户连接到Wi-Fi模块创建的网络(需要输入密码) – 请参阅附图 。 服务器(Wi-FI模块)IP地址是172.1.4.155(例如)但是当我尝试使用GetLocalIPAddress() (下面附带)在Xamarin.Forms中获取IP地址时,它返回的地址是本地IP地址设备(电话) – 172.1.4.55(例如)。 我需要能够在没有应用程序中的用户输入的情况下以编程方式获取IP地址。 有没有办法获取(外部)非设备特定IP地址的IP地址? 我假设手机返回的IP地址是DHCP分配的IP地址。 我需要获取服务器IP地址,因为在手机和WiFi模块之间建立TCP套接字连接至关重要。 我一直在努力寻找一个没有任何成功的解决方案,所以任何帮助/建议或示例将不胜感激。 下面的代码是获取IP地址的GetLocalIPAddress()函数。 public static string GetLocalIPAddress() { var host = Dns.GetHostEntry(Dns.GetHostName()); foreach (var ip in host.AddressList) { if (ip.AddressFamily == AddressFamily.InterNetwork) { return ip.ToString(); } //return “”; } //throw new Exception(“Local IP Address Not Found!”); return “None”; }

点击列表视图项目上的手势

我在点击列表视图中的项目后尝试打开另一个视图。 我尝试添加TapGestureRegonizer ,甚至添加带网格的ViewCell等。这些似乎都不起作用。 我已经为标签添加了一个轻击手势,这似乎有效,但同样不适用于列表视图项目。 这看起来像列表视图这样的简单问题,但似乎没有内置的function。 Xaml: 背后的代码: var listviewgesture = new TapGestureRecognizer(); listviewgesture.SetBinding(TapGestureRecognizer.CommandProperty,”LoadRoutePage”); dataList.GestureRecognizers.Add(listviewgesture); 视图模型: public ICommand LoadRoutePage { get; protected set; } public DriverDashboardViewModel(INavigation navigation,MessagDatabase database) { this._database = database; this.Navigation = navigation; this.LoadNotifications = new Command(async () => await OpenNotificationsPage()); this.LoadRoutePage = new Command(async () => await OpenRoutePage()); } public async Task OpenRoutePage() […]

每隔几秒自动刷新或更新内容页面

我正在使用Xamarin.forms ( PCL ),我需要每隔几秒刷新/更新内容页面及其数据。 在viewmodel从API检索数据。 是否有任何方法或处理程序可以定期在page.xaml.cs定期调用Get Api ,如: methodRunPeriodically() { userdata = await UserService.GetUserasync(_UserViewModel.EmployeeId); }

Xamarin表示Android MapRenderer

我为Xamarin iOS成功创建了一个ViewRenderer,现在我正在尝试为Android实现一个Renderer,这里是我需要在Android中实现的Map: public class MapViewModel : Map { public static readonly BindableProperty LocationsProperty = BindableProperty.Create<MapViewModel, List>(x => x.Locations, new List()); public static readonly BindableProperty PinTappedCommandProperty = BindableProperty.Create(x => x.PinTapped, null); public MapViewModel(List locations) { Locations = locations; PinTapped = new Command(async (x) => { //await Navigation.PopModalAsync(); var info = new InformationView((Branch)x); await Navigation.PushAsync(info); }); } […]

地理定位不适用于iOS PCL Xamarin表单

我试图通过此示例https://github.com/XLabs/Xamarin-Forms-Labs/wiki/Geolocator获取设备位置。 这适用于模拟器,但在iPad Air上不起作用。 我的info.plist文件包含位置的所有必要密钥。,NSLocationUsageDescription和NSLocationWhenInUseUsageDescription 在代码中 if (this.manager.RespondsToSelector(new Selector(“requestWhenInUseAuthorization”))) { this.manager.RequestWhenInUseAuthorization(); } 使用Geolocator对象的一段代码.. IGeolocator geolocator = null; geolocator = DependencyService.Get(); if (geolocator != null) { if (geolocator.IsGeolocationEnabled) { try { if (!geolocator.IsListening) geolocator.StartListening(1000, 1000); var task = await geolocator.GetPositionAsync(10000, CancellationToken.None); if(task != null) { this.Position = task; } 但是LocationUpdated事件永远不会发生…… 设备上的位置已开启。 如果有人有类似的问题…….请帮助…..一旦,这项工作在模拟器上。 我在iPad Air上使用VS 2013,Xamarin 3.7,Xamarin.iOS 8.4,iOS […]

如何在Xamarin Forms Cross-Platform中绑定图像集合

在WPF ,我可以轻松地将一组图像源绑定到带有图像模板的WrapPanel ,例如: 我找不到替代的Cross-platform Xamarin Forms将我的Image集合绑定到任何基于面板的控件的方法。

无法在Xamarin.Forms Visual Studio 2015中加载memtrack(无此类文件或目录)错误

我在Visual Studio 2015中创建了一个名为MyFifthTry的Xamarin.Forms应用程序。当我尝试在已经运行的模拟器(Bluestacks 2)上部署MyFifthTry.Droid项目时,部署失败。 Visual Studio的ErrorList中没有错误,但Android设备日志(logcat)给出了以下三个错误: 1)无法加载memtrack(没有这样的文件或目录) 2)无法加载memtrack模块:-2 3)打开跟踪文件时出错:没有这样的文件或目录(2) 我在互联网上搜索了这些错误并发现了许多问题和答案,但没有一个帮助我,因为他们都是关于Android Studio和Java的,因此我无法在我的项目中应用这些解决方案。 我认为这是关于Xamarin.Forms上的这个错误的一个新问题。 任何帮助将不胜感激。 编辑:这些错误也存在: Java.io.IOException:连接被拒绝 接受stdout和stderr(127.0.0.1:8944)时出错:地址已在使用中 在启动注册期间无法加载程序集“FormsViewGroup”。 这可能是由于调试安装无效。 一个常见的原因是直接“adb安装”应用程序,而不是从IDE执行。 虽然我从IDE启动了应用程序,但我收到了最后一个错误。

安排警报管理器每周四运行一个方法

例如,我希望每周四中午12点发出警报我该怎么做? 我有一些实施,但没有正常工作,我的代码,今天是星期三15,如果将手机的日期更改为16星期四,该应用程序没有做任何事情,如果我在下周三更改手机的日期22电话发送通知,但只应在星期四发送。 这是我的代码: 主要活动: protected override void OnCreate(Bundle bundle) { TabLayoutResource = Resource.Layout.Tabbar; ToolbarResource = Resource.Layout.Toolbar; base.OnCreate(bundle); AsNumAssemblyHelper.HoldAssembly(); global::Xamarin.Forms.Forms.Init(this, bundle); ImageCircleRenderer.Init(); Intent alarmIntent = new Intent(this, typeof(AlarmReceiver)); PendingIntent pending = PendingIntent.GetBroadcast(this, 0, alarmIntent, PendingIntentFlags.UpdateCurrent); AlarmManager alarmManager = GetSystemService(AlarmService).JavaCast(); //AlarmType.RtcWakeup – it will fire up the pending intent at a specified time, waking up the device […]

通过Xamarin将video上传到Azure存储

我正在尝试将video文件上传到我的Azure存储帐户。 我已经使用了图像,但是尝试查看上传的video会显示“不支持video格式或MIME类型”的消息。 video格式为mp4。 我使用以下代码上传: public async Task UploadVideo(Stream video, string path) { var container = GetContainer(“videos”); // Creates the container if it does not exist await CreateContainer(container); //Gets the file extension string lastPart = path.Split(‘.’).Last(); // Uploads the video to the blob storage CloudBlockBlob videoBlob = container.GetBlockBlobReference(path); videoBlob.Properties.ContentType = “video/” + lastPart; await videoBlob.UploadFromStreamAsync(video); } […]

Xamarin表单ListView分组绑定问题

我一直试图玩Xamarin Forms一段时间,然后遇到了Listview Grouping。 我没有完成显示空白列表。 请帮我找一下我错的地方? 提前致谢 但是,我的类域看起来像: public class LineItemTaxDto { public int InvoiceLineItemId { get; set; } public int InvoiceId { get; set; } public int TaxId { get; set; } public decimal TaxRate { get; set; } public decimal TaxAmount { get; set; } public string TaxName { get; set; } } 我的视图模型属性看起来像 […]