小编Bin*_*Tie的帖子

如何删除或隐藏特定页面错误中的工具栏项:System.IndexOutOfRangeException:索引超出了数组的范围

我想Remove()Clear() ToolbarItems.这是我ToolbarItem在MainPage.cs中创建的代码

public partial class MainPage : MasterDetailPage
{
   public ToolbarItem cCounter = new ToolbarItem() { Icon = "picture.png" };
   public ToolbarItem pPo = new ToolbarItem() { Text = "-" };

   public MainPage()
    {
        InitializeComponent();
        if (Device.OS == TargetPlatform.iOS)
        {
            provider.Clicked += iOS_Ppo_Clicked;
            ToolbarItems.Add(cCounter);
            ToolbarItems.Add(pPo);
        }
    }

    private void iOS_Ppo_Clicked(object sender, EventArgs e)
    { 
        OpenWindow();            
    }

    public async void OpenWindow()
    {
        if (await Common.WindowComands.CanOpenWindow<PPoPage>(Detail))
        {  
            page = new PPoPage(Page3.Allproviders);

            this.ToolbarItems.Clear(); // here I am …
Run Code Online (Sandbox Code Playgroud)

c# xamarin.ios toolbaritems xamarin xamarin.forms

15
推荐指数
1
解决办法
3339
查看次数

Outlook webmail访问mailto正文是空白的

我正在尝试mailto为Outlook(网络版)创建一个网址.

在Outlook上,一切都运行得很好,但现在我必须在网络版OWA上实现它,所以我正在努力使用这个网址:

<a href='https://company.domain.com/owa/?ae=Item&a=New&t=IPM.Note&to=someone@expample.com&subject=Hello%20again&body=Body%20Text' target=_blank>testy</a>
Run Code Online (Sandbox Code Playgroud)

因为身体部位是空的.关于发生了什么的任何想法?

html mailto email url outlook-web-app

7
推荐指数
1
解决办法
699
查看次数

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

我正在努力解决这个问题.我在这里创建了一个简单的跨平台页面是XAML代码:

<?xml version="1.0" encoding="utf-8" ?>
<CarouselPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="ForTesting.TestPage">
  <Label Text="{Binding MainText}" VerticalOptions="Center" HorizontalOptions="Center" />
  <ContentPage>
    <ContentPage.Padding>
      <OnPlatform x:TypeArguments="Thickness" iOS="0,40,0,0" Android="0,40,0,0" />
    </ContentPage.Padding>
  </ContentPage>
</CarouselPage>
Run Code Online (Sandbox Code Playgroud)

这里是相同的跨平台页面类:

public partial class TestPage: CarouselPage
    {
        public TestPage()
        {
            InitializeComponent();
            new Label
            {
                Text = "heelow",
                FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)),
                HorizontalOptions = LayoutOptions.Center
            };
         }
    }
Run Code Online (Sandbox Code Playgroud)

为了测试我创建了简单的标签,但即使没有标签它也不起作用.

我在我的MainPage.xaml中调用此页面:

<?xml version="1.0" encoding="UTF-8"?>
<MasterDetailPage xmlns="http://xamarin.com/schemas/2014/forms"
                  xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                  xmlns:local="clr-namespace:ForTesting;assembly=ForTesting"
                  x:Class="ForTesting.MainPage"
          MasterBehavior="Popover">
  <ContentPage.ToolbarItems>
    <ToolbarItem x:Name="CClick"
                 Text="C :"
                 Order="Primary">
    </ToolbarItem>
  </ContentPage.ToolbarItems>
  <MasterDetailPage.Master>
    <local:MasterPage x:Name="masterPage" />
  </MasterDetailPage.Master>
  <MasterDetailPage.Detail>
    <NavigationPage>
      <x:Arguments>
        <local:TestPage/> …
Run Code Online (Sandbox Code Playgroud)

c# xaml xamarin xamarin.forms

6
推荐指数
3
解决办法
2万
查看次数

如何在一种方法上用不同的情况编写断言测试,并且在与不同的响应案例进行比较时,所有这些都通过了?

是否可以测试许多情况,例如:

[TestCase(""), TestCase(null), TestCase("String"), TestCase("2010-07-14T00:00:00.000Z"), TestCase("201-07-14T00:00:00.000Z")]
Run Code Online (Sandbox Code Playgroud)

当我从带有反序列化json的API获得响应到我的Error对象时,我认为响应主体消息和HttpStatusCode在API的不同VALIDATIONS之后是正确的,并且从我的断言中它是正确的.

我从Json反序列化为泛型类型的方法:

public TType GetResponseJsonAsObject<TType>(HttpResponseMessage content)
        {
                var contentResult = content.Content.ReadAsStringAsync().Result;
                var specialCase = JsonConvert.DeserializeObject<TType>(contentResult);
                return specialCase;
        }
Run Code Online (Sandbox Code Playgroud)

这是我的测试方法:

[TestCase(""), TestCase(null), TestCase("String"), TestCase("2010-07-14T00:00:00.000Z"), TestCase("201-07-14T00:00:00.000Z")]
        public void PostAPI_SpecialCaseRequestDate_WithError_ProceedsSuccessfully(string date)
        {
            // arrange
            SpecialCaseRequest data = new SpecialCaseRequest()
            {
                Name = "Test",
                ExpirationDateTime = date,
            };

            // act + assert 
            string json = JsonConvert.SerializeObject(data, Formatting.Indented);
            PostMethods sendJsonDemo = new PostMethods();
            var response = sendJsonDemo.SendJsonDemo(json);
            var responseBody = sendJsonDemo.GetResponseJsonAsObject<Error>(response); 
            Assert.IsNotNull(responseBody); 

            Assert.AreEqual("Date parameter cannot be empty string", responseBody.Message); …
Run Code Online (Sandbox Code Playgroud)

c# json unit-testing assert

5
推荐指数
1
解决办法
212
查看次数

C#如何显示comboBox值而不是显示对象名称

大约3个小时,我正在尝试解决此问题。我的组合框向我显示对象名称而不是一个值,例如:A 在此处输入图片说明

这是我的课:

namespace Supermarket
{
    public class WhareHouseTable
    {
        public string name { get; set; }
        public double cost { get; set; }
        public string offer { get; set; }
    }
}
Run Code Online (Sandbox Code Playgroud)

这是我的代码:

private void Form1_Load(object sender, EventArgs e)
        {
            List<WhareHouseTable> product = new List<WhareHouseTable>();
            product.Add(new WhareHouseTable { name = "A", cost = 0.63, offer = "Buy 2 for the price of 1" });
            product.Add(new WhareHouseTable { name = "B", cost = 0.20 });
            product.Add(new WhareHouseTable { name = "C", …
Run Code Online (Sandbox Code Playgroud)

c# foreach combobox list winforms

3
推荐指数
1
解决办法
3963
查看次数

正则表达式 拉丁字符过滤器和非拉丁字符过滤器

我正在开发一个程序,我需要过滤非拉丁字符的单词和句子。问题是,我只找到了拉丁字符单词和句子,但没有找到混合有拉丁字符和非拉丁字符的单词和句子。例如,“Hello”是拉丁字母单词,我可以使用以下代码来匹配它:

\n\n
Match match = Regex.Match(line.Line, @"[^\\u0000-\\u007F]+", RegexOptions.IgnoreCase);\n\nif (match.Success)\n{\n    line.Line = match.Groups[1].Value;\n}\n
Run Code Online (Sandbox Code Playgroud)\n\n

但我没有发现例如与非拉丁字母单词或句子混合的情况:“Hell\xc3\xb8 I am s\xc3\xb8mthing”。

\n\n

另外,有人可以解释什么是 RegexOptions.None 或 RegexOptions.IgnoreCase 以及它们代表什么?

\n

c# regex ascii non-ascii-characters

2
推荐指数
1
解决办法
5170
查看次数