我已经看到了一些问题,但没有发现一个有帮助的问题!我只想选择邮政编码的第一部分,基本上忽略了空格后的任何内容.我正在使用的代码是
SUBSTRING(PostCode, 1 , CHARINDEX(' ', PostCode ) -1)
Run Code Online (Sandbox Code Playgroud)
但是我得到传递给LEFT或SUBSTRING函数的无效长度参数!没有空值或空白但有一些只有第一部分.这是导致错误的原因,如果是这样的话,是什么工作?!
for和foreach循环之间的主要区别是什么?
在哪些场景中我们可以使用for而不是foreach,反之亦然.
是否可以用简单的程序来展示?
两者对我来说都是一样的.我无法区分它们.
有没有人可以向我解释Xamarin表格中的rowspan和columnspan如何?右,左,上,下参数有点令人困惑.
让我们将这段代码用于rowspan:
grid.Children.Add(new Label
{
Text = "Span two rows (or more if you want)",
TextColor = Color.Yellow,
BackgroundColor = Color.Navy,
XAlign = TextAlignment.Center,
YAlign = TextAlignment.Center
}, 2, 3, 1, 3);
Run Code Online (Sandbox Code Playgroud)
数字2,3,1,3在列和行方面的含义是什么?这适用于具有四行三列的网格.
为什么这两个函数返回不同的值?
当我调用此函数传递0作为参数时,它返回1
public static int IncrementByOne(int number)
{
return (number + 1);
}
Run Code Online (Sandbox Code Playgroud)
但是,当我调用此函数传递0作为参数时它返回0,即使执行了增量并且数字变量在方法内将其值更改为1?
public static int IncrementByOne(int number)
{
return number++;
}
Run Code Online (Sandbox Code Playgroud)
这两个函数的返回值不同的原因是什么?
在我的应用程序中,我在My API调用期间收到包含4个pdf文档的ZIP文件.我正在使用以下代码保存ZIP文件.
var rootFolder = FileSystem.Current.LocalStorage;
var file = await rootFolder.CreateFileAsync(fileName, CreationCollisionOption.ReplaceExisting);
using (var fileHandler = await file.OpenAsync(FileAccess.ReadAndWrite))
{
await fileHandler.WriteAsync(document, 0, document.Length);
}
Run Code Online (Sandbox Code Playgroud)
保存文档后,
我如何解压缩并单独将pdf文档保存到手机内存中.任何人都可以指示我解决这个问题.我找到了SharpZipLib和Iconic zip库来解压缩代码; 但是如果在文档中找到了dot net实现,则不知道如何在Xamarin Forms中集成它.
请帮忙.
我是HttpClient的新手.我的代码总是在状态中显示"WaitingForActivation".请帮忙
private static async Task<HttpResponseMessage> MakeCall()
{
var httpclient = new HttpClient();
var response = await httpclient.GetAsync("http://localhost:60565/Subscribers");
return response;
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用 ASP.NET Identity 在 Web 应用程序上启用授权和身份验证。我正在尝试使用 SignInManager,但是当它调用 PasswordSignInAsync 时,它正在寻找数据库。有没有办法将其与内存数据(例如用户集合)一起使用以进行测试?
我正在使用默认的 ApplicationUser 类(模型)。
public class ApplicationUser : IdentityUser
{
public Guid UserId { get; set; }
public string Name { get; set; }
public string Password { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
这是控制器上的 Login ActionResult 方法。
[HttpPost]
public async Task<ActionResult> Login(LoginViewModel viewModel, string returnUrl)
{
if (ModelState.IsValid)
{
var signInResult = await _signInManager.PasswordSignInAsync(viewModel.Email, viewModel.Password,
true, false);
if (signInResult.Succeeded)
......
}
}
Run Code Online (Sandbox Code Playgroud)
_signInManager.PasswordSignInAsync 调用查找数据库,但我没有看到任何有用的重载来执行任何不同的操作。
我尝试在加载页面时填充绑定到 ObservableCollection 的 ListView 失败。目前,我使用以下代码使用按钮(绑定到命令)。
看法:
<Button Text="Load Items" Command="{Binding LoadItemsCommand}"></Button>
<ActivityIndicator IsRunning="{Binding IsBusy}" IsVisible="{Binding IsBusy}" />
<ScrollView>
<ListView ItemsSource="{Binding Items}">
.....
</ListView>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
查看.cs:
private ItemsViewModel _itemsViewModel;
public ItemsView()
{
InitializeComponent();
_itemsViewModel = new ItemsViewModel();
BindingContext = _itemsViewModel;
}
Run Code Online (Sandbox Code Playgroud)
视图模型:
public ObservableCollection<Item> Items{ get; set; }
public Command LoadItemsCommand { get; set; }
public ItemsViewModel()
{
Items = new ObservableCollection<Item>();
_isBusy = false;
LoadItemsCommand = new Command(async () => await LoadItems(), () => !IsBusy);
}
public async Task LoadItems() …Run Code Online (Sandbox Code Playgroud) 我正在使用FormattedString在Xamarin.Forms上的Label上显示自定义文本.我想要实现的是改变一个或多个元素的颜色,例如:$$ $$.但即使我改变颜色,Label也会显示所有具有相同颜色的美元符号:$$$$
这是视图上的标签:
<Label Text="{Binding AveragePrice, StringFormat='{0}'}" HorizontalTextAlignment="Center" />
Run Code Online (Sandbox Code Playgroud)
这是绑定到ViewModel上的标签文本的属性的代码
public FormattedString AveragePrice
{
get
{
return new FormattedString
{
Spans =
{
new Span { Text = "$", ForegroundColor=Color.Black },
new Span { Text = "$", ForegroundColor=Color.Black },
new Span { Text = "$", ForegroundColor=Color.Gray },
new Span { Text = "$", ForegroundColor=Color.Gray }
}
};
}
}
Run Code Online (Sandbox Code Playgroud)
为什么这段代码不会改变美元符号的颜色?我怎样才能实现呢?
将 Prism 用于 Xamarin Forms,我有一个像这样的 ListView:
<ListView ItemsSource="{Binding Conditions}">
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<Grid Margin="4" RowSpacing="0">
<Button Command="{Binding DoSomething}"/>
</Grid>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Run Code Online (Sandbox Code Playgroud)
其中 Condition 是 ConditionViewModel 的 ObservableCollection,DoSomething 命令位于页面的 ViewModel 中。
所以,当然,绑定在这里不起作用,因为它的 bindingcontext 将是一个单独的 ConditionViewModel 项目。
我知道相对绑定在 Xamarin 中不可用,并且规定的解决方案似乎是直接应用 {x:Reference SomeViewModel}。但是使用 Prism,View 不能直接访问它的 ViewModel,所以这是不可能的。
我也看过这个,试图获得一个 RelativeContext 标记扩展:https : //github.com/corradocavalli/Xamarin.Forms.Behaviors/blob/master/Xamarin.Behaviors/Extensions/RelativeContextExtension.cs 但是,得到RootObject 为空的异常。
还有其他解决办法吗?
我正在尝试这样做:
const string intType = typeof(int).ToString();
switch (typeof(MyT).ToString())
{
case intType:
{
return "int";
break;
}
...
}
Run Code Online (Sandbox Code Playgroud)
但编译说:
错误CS0133:分配给'intType'的表达式必须是常量
据我所知,typeof运算符在编译时工作.那么,怎么了?
c# ×9
xamarin ×4
.net ×2
asp.net ×1
asp.net-core ×1
asp.net-mvc ×1
async-await ×1
compilation ×1
data-binding ×1
dotnetzip ×1
for-loop ×1
foreach ×1
function ×1
grid ×1
increment ×1
layout ×1
mvvm ×1
prism ×1
sharpziplib ×1
tostring ×1
typeof ×1
xaml ×1