我正在寻找一种方法将Xamarin.Forms.Color转换为平台特定的颜色.例如适用于Android的Android.Graphics.Color.
我看了一下像R,G和B这样的Xamarin.Forms.Color的属性.这些值只包含0或1,所以看起来似乎毫无价值.有人经历过并解决过这个问题吗?
我想知道在我构建页面时设备的方向(Android,iOS和Windows Phone).页面有一个包含3个列定义的网格,一旦方向更改为横向,就应该有5个列定义.
Grid grid = new Grid
{
HorizontalOptions = LayoutOptions.Fill,
VerticalOptions = LayoutOptions.Fill,
RowSpacing = 15,
ColumnSpacing = 15,
Padding = new Thickness(15),
ColumnDefinitions =
{
new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) },
new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) },
new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }
}
};
for (int i = 0; i < 12; i++)
{
Image img = new Image()
{
Source = "ButtonBlue.png"
};
//if(DependencyService.Get<IDeviceInfo>().IsPortraitOriented())
//{
grid.Children.Add(img, i …Run Code Online (Sandbox Code Playgroud) 我的 Xamarin 应用程序中遇到一个恼人的错误。该解决方案包含一个 Android 项目和一个可移植类库。在可移植类库中,我有一个类,它使用一种方法与 SignalR 集线器进行通信InitiateConnection
HubConnection conn= new HubConnection(_url);
// Some events will be registrated on the HubConnection here...
if (!string.IsNullOrWhiteSpace(_userName))
{
conn.Credentials = new System.Net.NetworkCredential(_userName, _password);
}
await conn.Start();
Run Code Online (Sandbox Code Playgroud)
一旦我在调试版本中使用上述方法,它就会正常工作并且我正在接收数据。如果在发布版本中调用此方法,则会引发异常。首先是 Xamarin 未处理的异常。按下继续后,我收到以下异常:
System.InvalidOperationException: Server negotiation failed.
Unhandled Exception:
System.InvalidOperationException: Server negotiation failed.
at Microsoft.AspNet.SignalR.Client.Transports.TransportHelper.<GetNegotiationResponse>b__1 (System.String raw) [0x00000] in <filename unknown>:0
at Microsoft.AspNet.SignalR.TaskAsyncHelper+<>c__DisplayClass19`2[System.String,Microsoft.AspNet.SignalR.Client.NegotiationResponse].<Then>b__17 (System.Threading.Tasks.Task`1 t) [0x00000] in <filename unknown>:0
at Microsoft.AspNet.SignalR.TaskAsyncHelper+TaskRunners`2+<>c__DisplayClass3a[System.String,Microsoft.AspNet.SignalR.Client.NegotiationResponse].<RunTask>b__39 (System.Threading.Tasks.Task`1 t) [0x00000] in <filename unknown>:0
--- End of stack trace from previous location where exception …Run Code Online (Sandbox Code Playgroud) 我有一个包含多个项目的 iFrame,我想更新一个记录。
const frame = await page.frames()[1];
const P1_CUSTOM_NAME = await frame.$('#P1_CUSTOM_NAME');
await P1_CUSTOM_NAME.type('MyFavoritCustomer', {delay: 20});
Run Code Online (Sandbox Code Playgroud)
这不会覆盖该字段P1_CUSTOM_NAME。不幸的是,它附加了值'MyFavoritCustomer'。
任何建议我如何清除项目价值?
我正在以下while语句中逐行读取StreamReader中的数据.
while (!sr.EndOfStream)
{
string[] rows = sr.ReadLine().Split(sep);
int incr = 0;
foreach (var item in rows)
{
if (item == "NA" | item == "" | item == "NULL" | string.IsNullOrEmpty(item) | string.IsNullOrWhiteSpace(item))
{
rows[incr] = null;
}
++incr;
}
// another logic ...
}
Run Code Online (Sandbox Code Playgroud)
代码工作正常,但由于巨大的csv文件(500,000,000行和数百列),它非常慢.有没有更快的方法来检查数据(如果它是"NA","",......应该被替换为null).目前我正在使用带有incr变量的foreach来更新foreach中的项目.
我想知道linq或lambda会更快但我在这些方面很新.