Tag: xamarin.forms

如何使用xamrian表单提示用户进行地理定位

您好我正在使用xamrian表单应用程序中的应用程序,需要请求gelocation权限,如果授权它需要从设备获取地理位置数据,然后将地理位置坐标放入forecast.io URL我正在使用Geolocator插件詹姆斯·蒙特马尼奥以及詹姆斯·蒙特马尼奥的PermissionsPlugin,当我打开雷达页面时,屏幕保持白色,它永远不会要求我的许可,这是我的xamrain表单代码: using AppName.Data; using Xamarin.Forms; using Plugin.Geolocator; using System.Diagnostics; using System.Threading.Tasks; using Plugin.Permissions; using Plugin.Permissions.Abstractions; using System; namespace AppName.Radar { public partial class RadarHome : ContentPage { public RadarHome() { InitializeComponent(); } async void locator() { try { var status = await CrossPermissions.Current.CheckPermissionStatusAsync(Permission.Location); if (status != PermissionStatus.Granted) { if (await CrossPermissions.Current.ShouldShowRequestPermissionRationaleAsync(Permission.Location)) { await DisplayAlert(“Need […]

Xamarin.Forms:如何从Web API数据填充饼图?

今天是个好日子。 我正在创建一个Xamarin.Forms便携式应用程序。 我目前正在编写一个包含静态数据的 PieChart(OxyPlot)。 我想要做的是在我拥有的每个Pie Slice中都有一个动态数据 。 意思是,数据应来自我的数据库。 我已经能够从我的数据库中检索数据并将其显示为我正在使用Web Api创建的移动应用程序中的List ,如下所示: ClientListPage.xaml ClientListPage.xaml.cs using Newtonsoft.Json; using OxyPlot; using OxyPlot.Series; using System; using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Net.Http.Headers; using System.Text; using System.Threading.Tasks; using System.Windows.Input; using Xamarin.Forms; using XamarinFormsDemo.Models; using XamarinFormsDemo.ViewModels; namespace XamarinFormsDemo.Views { public partial class ClientListPage : ContentPage { CustomerVM viewModel; public ClientListPage() […]

ListView不会取消选择

我正在使用ListView进行Xamarin.Forms项目。 ListView的XAML是 而C#是 public void ItemTapped(object sender, ItemTappedEventArgs e) { var Selected = e.Item as Classes.NavigationItem; //Handle clicked } ((ListView)sender).SelectedItem = null; } private void ItemSelected(object sender, SelectedItemChangedEventArgs e) { ((ListView)sender).SelectedItem = null; } 我的自定义渲染器是 Android(自定义列表视图): public class NavigationListViewAndroid : ListViewRenderer { #pragma warning disable CS0618 // Type or member is obsolete public NavigationListViewAndroid() { […]

Xamarin Forms,使用async来应用ListView ItemSource

我目前正在使用Xamarin Forms,我使用的是从github RESTAPI获得的post方法。 每当我尝试将数据应用到ListView ItemsSource时,我的应用程序崩溃。 以下是当前执行的成功回调,它检索JSON并将其序列化并将其存储在名为listData的列表中。 public class Home : ContentPage { private ListView myListView; private List listInfo = new List { }; RESTAPI rest = new RESTAPI(); Uri address = new Uri(“http://localhost:6222/testBackEnd.aspx”); public Home () { Dictionary data = new Dictionary(); rest.post(address, data, success, null); Content = new StackLayout { Children = { myListView […]

Xamarin.Forms HTTPS和自签名证书问题

我正在使用Xamarin.Forms,我的优先级是UWP。 我试图通过System.Net.Http.HttpClient发布一个post请求,我的代码看起来像这样 public async Task Login(User user) { HttpClient client = await GetClient(); var response = await client.PostAsync(Url, new StringContent(JsonConvert.SerializeObject(user), Encoding.UTF8, “application/json”)); var mobileResult = await response.Content.ReadAsStringAsync(); var result = JsonConvert.DeserializeObject(mobileResult); return result; } 当我提出请求时,我收到此错误 System.Net.Http.HttpRequestException:发送请求时发生错误。 —> System.Runtime.InteropServices.COMException:找不到与此错误代码关联的文本。 证书颁发机构无效或不正确 在System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务)的System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)在System.Net.Http.HttpHandlerToFilter.d__4.MoveNext()—堆栈跟踪结束抛出exception的前一个位置— System.Runtime.Compiler服务上的System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务),System.Net.Http.HttpClientHandler.d__86.MoveNext的System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务) )—内部exception堆栈跟踪的结束—在System.Net.Http.HttpClientHandler.d__86.MoveNext()—从抛出exception的先前位置的堆栈跟踪结束—在System.Runtime.CompilerServices System.Net.Http.HttpClient.d__58.MoveNext()的System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)中的.TaskAwaiter.ThrowForNonSuccess(任务任务)—来自先前位置的堆栈跟踪结束 rown —位于System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务任务)的System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务任务), 1.GetResult() at SampleApp.Services.LoginService.d__2.MoveNext() — End of stack trace from previous […]

在运行时更改xamarin.forms颜色

我正在使用xamarin.forms创建一个应用程序,我已经设置了一个颜色方案,我希望能够在设置中更改为黑暗风格或轻量级风格现在它都可以工作除了我必须每次都重新启动应用程序之后我选择了不同的配色方案。 这是我试图在运行时更改它的地方 private void DarkThemeClick(object sender, EventArgs e) { database.DropTable(new StyleModel()); database.CreateTable(new StyleModel()); database.SaveItem(new StyleModel() { ThemeNum = 1 }); App.ActiveStyle = new DarkStyle(); } private void LightThemeClick(object sender, EventArgs e) { database.DropTable(new StyleModel()); database.CreateTable(new StyleModel()); database.SaveItem(new StyleModel() { ThemeNum = 0 }); App.ActiveStyle = new LightStyle(); } 这是我正在使用的项目的一个示例我想要更改颜色 using System; using TestXamForms.Style; using Xamarin.Forms; […]

如何编写一个在C#中打开图像的方法,该方法将使用移动设备上的默认图像查看器……?

为长标题道歉! 我在大学里学到的C#(可能只有2-3个月的具体知识)相当新… 我一直在尝试使用Xamarin Forms XAML,我想知道如何在代码隐藏中编写一个方法,打开要在Android或iOS的默认图像查看器中打开的抽头图像。 我说Android或iOS因为我正在做跨平台的Xamarin Forms PCL。 谢谢:)节日快乐,新年快乐:D!

Xamarin表单按钮OnClick

我目前在我的项目中有一个ContentPage.cs,使用Xamarin Forms作为工作环境,我只是想知道我是否能够为代码末尾的按钮添加OnClick。 非常感谢任何帮助。 提前致谢。 使用系统; 使用Xamarin.Forms; namespace DebuggerTestAndroidIOS {public class VSParameters:ContentPage {public VSParameters(){Content = new StackLayout {Children = {new StackLayout {BackgroundColor = Color.FromHex(“0ADF80”),Children = { new Label { Text = PatientInformation.PatientName, TextColor= Color.White, FontSize = 25 } } }, //Patient Information Stack Layout new StackLayout{ Orientation = StackOrientation.Horizontal, Children = { //Patient Image, sex and […]

ListView不会滚动分组

我只是将我的ListView更改为使用分组,但现在我不能再使用ScrollTo了。 我创建了一个简单的应用程序,因此您可以看到问题所在。 XAML页面看起来像(我现在不在我的应用程序中使用XAML,但我将在即将推出的版本中使用)。 并且示例的代码隐藏文件看起来像这样 [XamlCompilation(XamlCompilationOptions.Compile)] public partial class ProjectPage : ContentPage { public ProjectPage() { InitializeComponent(); BindingContext = new ProjectsViewModel(); } protected override void OnAppearing() { base.OnAppearing(); Acr.UserDialogs.UserDialogs.Instance.ShowLoading(); var projects = Newtonsoft.Json.JsonConvert.DeserializeObject<IList>(“[{\”ProjectName\”:\”Test sag\”,\”ProjectReference\”:\”10072\”,\”CustomerName\”:\”Test firma\”,\”FullAddress\”:\”Testvej 3\”,\”StartDate\”:\”2017-02-02T00:00:00\”,\”StartTime\”:\”\”},{\”ProjectName\”:\”aaa\”,\”ProjectReference\”:\”10077\”,\”CustomerName\”:\”Test firma\”,\”FullAddress\”:\”Testvej 12\”,\”StartDate\”:\”2017-02-08T00:00:00\”,\”StartTime\”:\”\”},{\”ProjectName\”:\”Test\”,\”ProjectReference\”:\”10082\”,\”CustomerName\”:\”Test firma\”,\”FullAddress\”:\”Testvej 50\”,\”StartDate\”:\”2017-02-16T00:00:00\”,\”StartTime\”:\”\”},{\”ProjectName\”:\”Test\”,\”ProjectReference\”:\”10085\”,\”CustomerName\”:\”Testvej boligselskab\”,\”FullAddress\”:\”Testvej 14\”,\”StartDate\”:\”2017-02-24T00:00:00\”,\”StartTime\”:\”\”},{\”ProjectName\”:\”Test\”,\”ProjectReference\”:\”10086\”,\”CustomerName\”:\”Testing\”,\”FullAddress\”:\”Testevej 14\”,\”StartDate\”:\”2017-02-27T00:00:00\”,\”StartTime\”:\”\”},{\”ProjectName\”:\”Test1\”,\”ProjectReference\”:\”10087\”,\”CustomerName\”:\”Plejecenter testlyst\”,\”FullAddress\”:\”Testlystvej 11\”,\”StartDate\”:\”2017-02-27T00:00:00\”,\”StartTime\”:\”\”},{\”ProjectName\”:\”Test2\”,\”ProjectReference\”:\”10088\”,\”CustomerName\”:\”Charlie\”,\”FullAddress\”:\”Testvej 50\”,\”StartDate\”:\”2017-02-27T00:00:00\”,\”StartTime\”:\”\”},{\”ProjectName\”:\”Test\”,\”ProjectReference\”:\”10089\”,\”CustomerName\”:\”Standard Debitor\”,\”FullAddress\”:\”[Mangler]\”,\”StartDate\”:\”2017-03-16T00:00:00\”,\”StartTime\”:\”\”},{\”ProjectName\”:\”Test\”,\”ProjectReference\”:\”10090\”,\”CustomerName\”:\”Standard Debitor\”,\”FullAddress\”:\”[Mangler]\”,\”StartDate\”:\”2017-03-16T00:00:00\”,\”StartTime\”:\”\”},{\”ProjectName\”:\”Test\”,\”ProjectReference\”:\”10091\”,\”CustomerName\”:\”Standard Debitor\”,\”FullAddress\”:\”[Mangler]\”,\”StartDate\”:\”2017-03-16T00:00:00\”,\”StartTime\”:\”\”},{\”ProjectName\”:\”Test\”,\”ProjectReference\”:\”10092\”,\”CustomerName\”:\”Tester\”,\”FullAddress\”:\”Testvej 11\”,\”StartDate\”:\”2017-03-16T00:00:00\”,\”StartTime\”:\”\”},{\”ProjectName\”:\”Test\”,\”ProjectReference\”:\”10093\”,\”CustomerName\”:\”Plejehjemmet test\”,\”FullAddress\”:\”Testvej 90\”,\”StartDate\”:\”2017-03-16T00:00:00\”,\”StartTime\”:\”\”},{\”ProjectName\”:\”Test\”,\”ProjectReference\”:\”10094\”,\”CustomerName\”:\”Plejehjemmet test\”,\”FullAddress\”:\”Testvej 90\”,\”StartDate\”:\”2017-03-16T00:00:00\”,\”StartTime\”:\”\”}]”); var viewModel […]

获取当前的ip-address Xamarin.Forms(跨平台)

如何获取Xamarin.Forms(跨平台)的当前IP地址? WifiManager我不能使用而且不能包含WifiManager?