我是xamarin.forms的新手,我需要添加一个复选框,单选按钮和下拉列表.我从网上尝试了一些样本,但我无法获得复选框.任何人都可以帮助我在xamarin.forms中实现这一目标吗?
Xaml文件
<toolkit:CheckBox Text ="Employee"
FontSize="20"
CheckedChanged ="OnClicked"/>
Run Code Online (Sandbox Code Playgroud)
要么
<controls:CheckBox DefaultText="Default text"
HorizontalOptions="FillAndExpand"
TextColor="Green"
FontSize="25"
FontName="AmericanTypewriter"/>
Run Code Online (Sandbox Code Playgroud)
一些链接或示例代码将使其更容易理解.
我有自动将StackPanel分解为下一行的问题.这是示例代码:
<StackPanel Orientation="Horizontal" Width="180">
<TextBlock.../>
<TextBlock.../>
<TextBlock.../>
<Image.../>
...
</StackPanel>
Run Code Online (Sandbox Code Playgroud)
现在我想要达到这样的效果:当StackPanel中没有足够的空间用于另一个元素时,它应该放在新行中.我怎么能得到这个(没有必要使用stackpanel)?
PS:我的目标是将文本和图像放在一行中(当没有足够的空间用于另一个元素时,它当然可以中断).也许你可以提供比使用文本块和图像更好的解决方案?
我正在尝试实现一种方法,其中存储在数据库中的活动关键字(用逗号分隔)与用逗号分隔的给定字符串匹配.
public List<TblActivities> SearchByMultipleKeyword(string keywords)
{
string[] keyword = keywords.Split(',');
var results = (from a in Entities.TblActivities
where a.Keywords.Split(',').Any(p => keyword.Contains(p))
select a).ToList();
return results;
}
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
LINQ to Entities does not recognize the method 'System.String[] Split(Char[])' method,
and this method cannot be translated into a store expression.
Run Code Online (Sandbox Code Playgroud) 我为Windows 10构建了一个通用应用程序,我不知道Native Tool链.当我准备创建包时,我遇到了很多错误,我找不到任何运气的解决方案.
经过几次尝试后,我决定将我的应用程序一块一块地放在一个测试项目中,看看出了什么问题,我添加了Mvvm Light 5.2的ViewModelLocator后出现了以下错误:
NUTC300F:Internal Compiler Error: Native compilation failed due to out of memory error
ILT0005: 'C:\Program Files (x86)\MSBuild\Microsoft\.NetNative\x86\ilc\Tools\nutc_driver.exe
@"C:\...\Test\obj\x86\Release\ilc\intermediate\MDIL\Test.rsp"' returned exit code 1
Warning Method 'CreateLambda' within 'System.Linq.Expressions.Expression' could not be found.
C:\....\Test\Resources.System.Linq.Expressions.rd.xml 35
Warning Method 'ParameterIsAssignable' within 'System.Linq.Expressions.Expression' could not be found.
C:\....\Test\Resources.System.Linq.Expressions.rd.xml 91
Run Code Online (Sandbox Code Playgroud)
这是我的ViewModelLocatorClass
public class ViewModelLocator
{
public const string HeroDetailsPageName = "HeroDetails";
public ViewModelLocator()
{
ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
var nav = new NavigationService();
nav.Configure(HeroDetailsPageName, typeof(HeroDetails));
SimpleIoc.Default.Register<INavigationService>(() => nav);
SimpleIoc.Default.Register<IDialogService, DialogService>();
if (ViewModelBase.IsInDesignModeStatic) …Run Code Online (Sandbox Code Playgroud) 我正在尝试以流方式编写一个非常大的XML文档.而不是写一个XDocument或者XElement可能消耗太多内存的想法是,我在使用a之前编写根元素XmlWriter,然后在关闭根元素之前一个接一个地向该编写器写入许多XElements.但是,我还没有找到办法.要模拟问题,请考虑以下代码:
using System;
using System.Xml;
using System.Xml.Linq;
internal static class Program
{
private static void Main()
{
var settings = new XmlWriterSettings { Encoding = Console.OutputEncoding, Indent = true };
using (var writer = XmlWriter.Create(Console.Out, settings))
{
const string namespaceUri = "http://example.com/";
writer.WriteStartElement("x", "root", namespaceUri);
XNamespace x = namespaceUri;
XElement element = new XElement(x + "test");
element.Save(writer);
writer.WriteEndElement();
}
Console.WriteLine();
}
}
Run Code Online (Sandbox Code Playgroud)
该程序element.Save(writer);在行上失败,其中包括InvalidOperationException:"状态元素开始标记中的标记StartDocument将导致无效的XML文档".
这个异常的原因很明显:XElement假设它拥有整个XmlWriter,并调用WriteStartDocument()它.显然失败了,因为文档已经启动,并且已经有一个启动元素.
请注意,如果我使用XDocument,我会期待这种行为,但我不是,我正在使用XElement …
我得到一个字符串数组,其中包含属性名称。我只想在获取数据时加载这些属性,在本例中是通过实体框架从数据库获取数据。就像是:
\n\nvar result = db.myTable\n .Where(x => x.Id == \xe2\x80\x9dsomeValue\xe2\x80\x9d)\n .Select(y => new {y.someProperty, y.someOtherproperty, ...});\nRun Code Online (Sandbox Code Playgroud)\n\n如何从字符串数组创建匿名对象。我想要这样的东西:
\n\nvar MyObj = new {};\nforeach(var I in MyStrinArr)\n{\n ... Add the properties here ...\n}\nvar result = db.myTable.Where(x => x.Id==\xe2\x80\x9dsomeValue\xe2\x80\x9d).Select(y => obj);\nRun Code Online (Sandbox Code Playgroud)\n 我正在使用Microsoft.CodeAnalysis.FxCopAnalyzers,CA1000规则如下。
不要在泛型类型上声明静态成员。
如何纠正违规行为
要修复违反此规则的问题,请删除静态成员或将其更改为实例成员。
何时抑制警告:
不要抑制此规则的警告。以易于理解和使用的语法提供泛型可以减少学习所需的时间并提高新库的采用率。
我的代码如下。该Success方法是触发规则的方法。
public class ResultResponse
{
internal ResultResponse(bool isSuccess)
{
IsSuccess = isSuccess;
}
public bool IsSuccess { get; }
public static ResultResponse Failed()
=> new ResultResponse(false);
}
public class ResultResponse<T> : ResultResponse
{
internal ResultResponse(T value, bool isSuccess)
: base(isSuccess)
{
Value = value;
}
public T Value { get; }
public static ResultResponse<T> Success(T value)
=> new ResultResponse<T>(value, true);
}
Run Code Online (Sandbox Code Playgroud)
我可以将构造函数公开并在上面的示例中使用它,但我也有这样的情况,我想将构造函数保留在内部以确保正确使用类型。
将Success方法移至非泛型类型是正确的方法吗?
public class ResultResponse …Run Code Online (Sandbox Code Playgroud) 我有以下LINQ语句,它从数据表中计算3个值.有时,其中一些值可能包含null.我如何将null合并为0.
var striko2scrap = from myrow in Scrap.AsEnumerable()
where myrow.Field<string>("MachineID") == "Striko 2"
group myrow by myrow.Field<string>("MachineID") == "Striko 2" into g
select new
{
TotalScrap = g.Sum(x => x.Field<int?>("Runners") ??
0 + x.Field<int?>("HouseIngots") ??
0 + x.Field<int?>("Other") ??
0)
} ;
Run Code Online (Sandbox Code Playgroud)
我试过了?0在不同的地方但我调试时仍然得到相同的结果.

好的,我正在尝试使用Xamarin.Auth对Xamarin.iOS进行非常基本的身份验证,并收到错误:"应用程序配置不允许给定URL:一个或多个给定的URL不允许应用程序的设置.它必须与网站URL或Canvas URL匹配,或者域必须是App域之一的子域."
我已经谷歌搜索了一段时间,似乎你可能再也无法使用Xam.Auth进行Facebook - 这似乎不太可能......
这是我的示例代码(没有我的FB应用程序ID) - 您会注意到它实际上是Xam的示例代码的副本:
using System;
using System.Collections.Generic;
using System.Json;
using System.Linq;
using System.Threading.Tasks;
using MonoTouch.Dialog;
#if __UNIFIED__
using Foundation;
using UIKit;
#else
using MonoTouch.Foundation;
using MonoTouch.UIKit;
#endif
namespace Xamarin.Auth.Sample.iOS
{
[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{
void LoginToFacebook (bool allowCancel)
{
var auth = new OAuth2Authenticator (
clientId: "SOME_ID",
scope: "",
authorizeUrl: new Uri ("https://m.facebook.com/dialog/oauth/"),
redirectUrl: new Uri ("http://www.facebook.com/connect/login_success.html"));
auth.AllowCancel = allowCancel;
// If authorization succeeds or is canceled, .Completed will be …Run Code Online (Sandbox Code Playgroud) 我制作了自定义用户控件,但在设置自定义属性时遇到问题.这是我遇到问题的代码,我不知道为什么我会收到堆栈溢出异常.任何帮助将非常感激.
displayList = new List<ItemDisplay>();
foreach (var item in InventoryData2.Items)
{
ItemDisplay id = new ItemDisplay();
id.Item = item;
id.Name = item.Item.ItemNumber;
id.Location = new System.Drawing.Point(0, displayList.Count * id.Height);
displayList.Add(id);
}
public InventoryItem Item
{
get { return Item; }
set {
Item = value;
lblItemNumber.Text = Item.Item.ItemNumber;
lblTitle.Text = Item.Item.Title;
lblModel.Text = Item.Item.Model;
lblPrice.Text = Item.Item.Price.ToString();
}
}
Run Code Online (Sandbox Code Playgroud) c# ×8
linq ×3
.net-core ×1
.net-native ×1
checkbox ×1
exception ×1
facebook ×1
linq-to-xml ×1
oauth-2.0 ×1
string ×1
uwp ×1
windows ×1
windows-8 ×1
winrt-xaml ×1
xamarin ×1
xamarin.ios ×1
xaml ×1
xml ×1