Tag: xamarin

在UWP中设置自定义WebView标头

这似乎与其他类似问题重复,但它们是旧线程,而不是Windows UWP应用程序特有的。 我无法在WebView中设置自定义标头,因此WebView中加载的URL可能对我有用。 我见过许多论坛提供的解决方案就像使用HttpClient / WebRequest一样使用标题但是在我的情况下不起作用,url使用Javascript进行重定向,在重定向之前需要很少的自定义标头来正确加载。 此外, WebView.NavigateWithHttpRequestMessage不太适合回发,我需要每个请求的标头,包括Web视图中的 javascript重定向URL。 我可以使用Renderers在Xamarin.Droid项目中设置自定义标题,但我找不到任何UWP Windows.UI.Xaml.Controls.WebView解决方案。

Xamarin Forms:System.Reflection.TargetInvocationException:调用目标抛出了exception

我正在努力解决这个问题。 我在这里创建了一个简单的跨平台页面是XAML代码: 这里是相同的跨平台页面类: public partial class TestPage: CarouselPage { public TestPage() { InitializeComponent(); new Label { Text = “heelow”, FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)), HorizontalOptions = LayoutOptions.Center }; } } 为了测试我创建了简单的标签,但即使没有标签它也不起作用。 我在我的MainPage.xaml中调用此页面: 在这一行上:ForTesting.MainPage.xaml.g.cs我在执行程序时遇到错误: public partial class MainPage : global::Xamarin.Forms.MasterDetailPage { [System.CodeDom.Compiler.GeneratedCodeAttribute(“Xamarin.Forms.Build.Tasks.XamlG”, “0.0.0.0”)] private global::Xamarin.Forms.ToolbarItem CClick; [System.CodeDom.Compiler.GeneratedCodeAttribute(“Xamarin.Forms.Build.Tasks.XamlG”, “0.0.0.0”)] private global::ForTesting.MasterPage masterPage; [System.CodeDom.Compiler.GeneratedCodeAttribute(“Xamarin.Forms.Build.Tasks.XamlG”, “0.0.0.0”)] private void InitializeComponent() { […]

Xamarin iOS C#在UIWebView中打开Safari中的链接

我在Xamarin使用C#编写带有UIWebView的iPhone应用程序。 默认情况下,Web视图中的嵌入式链接会在同一Web视图中打开Web页面。 我希望他们喜欢在新的safari浏览器实例中启动链接页面。 在X-Code中已经回答了目标C,但据我所知,Xamarin C# webView.LoadHtmlString(html, new NSUrl(Const.ContentDirectory, true)); 提前致谢 亚当

Xamarin.Forms按钮的内容

我正在尝试将自定义内容添加到Xamarin Forms中的按钮。 默认情况下,按钮创建如下: 但我想创建此按钮的自定义内容。 通常使用WPF,我会这样做: 但这不起作用。 我也在寻找一个DataTemplate属性,但还没有找到它。 如何在Xamarin.Forms中做到这一点?

使用xamarin.forms将映像的大小压缩为250kb,无需依赖服务

我正在尝试将Xamarin.Forms中从相机拍摄的图像压缩到250kb大小。 我找到了在依赖服务中做到这一点的方法,但我希望它没有依赖服务(纯xamarin.forms代码)。 怎么可能呢。 谁能建议我你有最好的方法? 提前致谢

可移植类库配置文件78缺少与属性相关的方法/属性

在我的PCL核心项目(WP8,Android,iOS,Xamarin,MvvmCross)中,我使用自定义属性。 Type.GetCustomAttributes()扩展方法让我检查使用的属性。 使用PCL Profile104这很有效。 但是因为我想使用async / await,我需要使用PCL Profile78(和.NET 4.5) 问题:看起来GetCustomAttributes()和Attributes属性在Profile78中不可用。 为什么?? 注意:我正在研究解决方法,方法是创建一个PCL Profile 104类库并包装GetCustomAttributes(),然后从我的PCL Profile78库中引用该库。 但是似乎不支持扩展方法…… 示例代码: public Pcl78Class() { Type t = this.GetType(); var attributes = t.Attributes; var customAttributes = t.GetCustomAttributes(true); // another weird thing: Why is VS CodeCompletion telling me it knows CustomAttributeExtensions class and methods? //System.Reflection.CustomAttributeExtensions.GetCustomAttributes(t); }

如何在一个Xamarin表单标签中有2个数据绑定字段?

你好,我有一个应用程序,我正在从xamrian froms工作,从服务获取数据。 我要做的是让名字和姓氏字段显示在同一标签中,但它当前显示名字然后它返回一行,然后显示姓氏。 inheritance我的xaml代码: 编辑这是我的代码隐藏: using Newtonsoft.Json; using ReadyMo.Data; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Net.Http; using System.Threading.Tasks; using Xamarin.Forms; namespace ReadyMo { public partial class ContactInfo : ContentPage { private County item; public static async Task GetContactString(string contactid) { HttpClient client = new HttpClient(); var url = $”URL”; var response = await client.GetAsync(url); […]

在xamarin表单上动态绑定图像源

我的问题是,我可以将字符串图像绑定到图像源吗? 我有多个图像,如果条件,图像将会改变。 所以: Xamal上的Xamlforms: Codebehind c# public String someImage; public String SomeImage { set { if (someImage != value) { someImage = value; } } get { return someImage; } } InitializeComponent部分: if(true) { someImage = “backgroundListViewGren.png”; } else { someImage = “backgroundListViewRed.png”; } 图像位于便携式项目的“Images”文件夹中 但是,这不起作用,也许我不会做什么,但我不明白。 有解决方案? 我尝试使用ImageSource而不是字符串,但也不用。

SQLite net PCL – 简单选择

我在Windows应用程序中使用SQLite,现在我在Xamarin开发一个便携式应用程序,所以我使用插件sqlite net pcl,我很难理解它是如何工作的。 我有一个由以下te创建的表: public class Config { public string IP { get; set; } [SQLite.Net.Attributes.Default(true, “Client 2”)] public string ID { get; set; } } 并创建表: db.CreateTable(); 问题:现在我想在ID列中选择值,然后执行以下操作: List hhid = db.Query(“select ID from Config”,null); 我得到这个例外: “Object reference not set to an instance of an object” 如何进行简单的选择以找到此字段? 谢谢你的提示

.Net CultureInfo Month Names返回一个额外的空字符串

我有以下代码来获取月份名称列表: var monthNames = System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.MonthNames; 出于某种原因,这会继续返回一个额外的空字符串值以及Month名称: 我正在使用Xamarin Studio。 之前有人遇到过这个吗?