小编Ger*_*uis的帖子

PHP - 检查变量是否未定义

考虑一下这个jquery语句

isTouch = document.createTouch !== undefined
Run Code Online (Sandbox Code Playgroud)

我想知道我们是否在PHP中有一个类似的语句,不是isset(),而是字面上检查一个未定义的值,如:

$isTouch != ""

在PHP中有类似的东西吗?

php

70
推荐指数
6
解决办法
18万
查看次数

20
推荐指数
3
解决办法
9844
查看次数

根据数据绑定值设置背景颜色

我以前见过一些答案,但没有什么能真正帮助我.

我也有一个类DecideModel(这将是从DB检索的数据集,但为了这个问题的目的,我添加了一个ObservableCollection),其中包含

static DecideModel()
    {
        All = new ObservableCollection<DecideModel>
        {
            new DecideModel
            {
                DatePerformed = new DateTime(2015, 4, 06),
                Result = "Maybe"
            },
            new DecideModel
            {
                DatePerformed = new DateTime(2015, 4, 05),
                Result = "No"
            },
            new DecideModel
            {
                DatePerformed = new DateTime(2015, 4, 04),
                Result = "Yes"
            }
        };
    }

    public DateTime DatePerformed { set; get; }

    public string  Result { set; get; }

    public static IList<DecideModel> All { set; get; }
}
Run Code Online (Sandbox Code Playgroud)

在我的XAML代码中

<ContentPage.Resources>
    <ResourceDictionary>
        <Color …
Run Code Online (Sandbox Code Playgroud)

xaml binding xamarin xamarin.forms

9
推荐指数
2
解决办法
7865
查看次数

Xamarin Forms - 让 webview 返回

大家早,

我正在 Xamarin.Forms 中开发一个小的跨平台 webview 项目。我有 webview 工作,但我想添加一个工具栏,它有一个后退和前进按钮。

我尝试了许多不同的方法,但似乎没有什么特别有效。我尝试通过关注这些人发布导航工具栏来实现此功能

我将在下面附上我的代码,如果有人可以帮我解决这个问题或解决方案,那就太好了!

如果另一个用户之前已经回答了这个问题,那么我深表歉意。

应用程序

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Xamarin.Forms;

namespace DisplayWebPage
{
    public class App : Application
    {
        public App()
        {
            // The root page of your application
            MainPage = new WebPage();
        }

        protected override void OnStart()
        {
            // Handle when your app starts
        }

        protected override void OnSleep()
        {
            // Handle when your app sleeps
        }

        protected override void OnResume()
        {
            // Handle when …
Run Code Online (Sandbox Code Playgroud)

c# android webview ios xamarin.forms

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

如何修复 Android 清单中的资源错误

我在使用 MAUI 的 RC1 时遇到问题,导致我从 Android 清单中删除了这部分:

    <application
      ...
      android:icon="@mipmap/appicon" 
      android:roundIcon="@mipmap/appicon_round"
      ...>
    </application>
Run Code Online (Sandbox Code Playgroud)

现在它已经 GA 了,我正在尝试将其添加回来,因为在 Android 中我的应用程序图标没有显示 - 相反,它只是通用的 Android 图标。当我将其添加回我的 Android 清单时,如下所示:

    <application android:allowBackup="true"
      android:supportsRtl="true"
      android:icon="@mipmap/appicon" 
      android:roundIcon="@mipmap/appicon_round">
    </application>
Run Code Online (Sandbox Code Playgroud)

我遇到编译错误,我不知道如何解决。注意:我确实有一个名为“appicon.png”的文件,并且它确实可以作为 iOS 上的应用程序图标正常工作。错误看起来像这样:

APT2260 resource xml/microsoft_maui_essentials_fileprovider_file_paths (aka com.watchlikes.watchlikesapp:xml/microsoft_maui_essentials_fileprovider_file_paths) not found.

APT2260 resource style/Maui.SplashTheme (aka com.watchlikes.watchlikesapp:style/Maui.SplashTheme) not found.

APT2067 failed processing manifest.
Run Code Online (Sandbox Code Playgroud)

如果我从清单文件中取出 android:icon 和 android:roundIcon 属性,它会再次正确编译。知道这个问题是什么,和/或如何解决它吗?

xml android maui

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

在每次创建上下文时发出 DbContext.OnModelCreating

我首先使用实体​​框架代码来处理我的数据库。我有几个名称不同但结构相同的表,并且这些表动态出现在数据库中。如何在运行时将 EntityFramework 映射到其中一个表并使用来自 DbContext 实体的数据?

我为使其发挥作用所做的工作:

例如,我的类描述动态创建表的结构是SetElement

这是我的背景:

public class DataContext : DbContext
{
    public DataContext()
        : base("RepositoryConnectionString") { }

    string setElementsTableId; // the name of table that need to be dynamicly mapped to 

    // Enforce model recreating
    public DataContext(string setElementsTableId)
        : this()
    {
        this.setElementsTableId = setElementsTableId;
    }


    /* some other entities */

    public DbSet<Entities.SetElement> SetElements { get; set; } // dynamicly mapped entity


    protected override void OnModelCreating(DbModelBuilder modelBuilder)
    {
        /* come configurations */

        if (!string.IsNullOrEmpty(setElementsTableId))
        {
            modelBuilder.Entity<Entities.SetElement>().Map(x …
Run Code Online (Sandbox Code Playgroud)

c# entity-framework entity-framework-6

4
推荐指数
1
解决办法
2110
查看次数

如何在Xamarin.Forms中创建图像按钮?

请告诉我们如何在Xamarin.Forms中创建图像按钮,我们不使用故事板.

环境:Mac上的Xamarin Studio

xamarin xamarin.mac xamarin.forms

4
推荐指数
1
解决办法
8095
查看次数

以xamarin形式获取纬度 - 经度的设备位置

我的应用程序中有一个扫描仪,当我扫描任何QR码时,我需要获得纬度 - 经度的设备的当前位置.我不知道如何获取位置,所以我现在没有任何代码.建议我一些方法来获取扫描完成QR码的位置.

c# location xamarin-studio xamarin.forms

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

如何在 xamarin 表单中使用打开文件对话框

请帮助我,我想以 xamarin 形式(跨平台)在本地选择 pdf 文件。因此,在单击按钮时,我需要打开文件对话框以在本地选择 pdf 文件。

xamarin.forms

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

如何从我们在xamarin.forms中的应用程序打开设置?

我正在研究xamarin.forms.(仅在android中遇到以下问题)

当我的应用程序启动时,它会检查我的GPS位置是打开还是关闭.

要打开或关闭GPS位置我正在使用依赖服务.

public static bool CheckGPSConnection()
        {
            var gpsConnection = DependencyService.Get<IGPSConnectivity>();
            return gpsConnection.CheckGPSConnection();
        }
Run Code Online (Sandbox Code Playgroud)

当我来到我的应用程序的主页时,我把下面的代码

if (Device.OS == TargetPlatform.Android)
{
    if (!App.CheckGPSConnection())
    {
        bool answer = await DisplayAlert("Alert", "Would you like to start GPS?", "Yes", "No");
        if (answer)
        {
              Android.App.Application.Context.StartActivity(new Android.Content.Intent(Android.Provider.Settings.ActionLocationSourceSettings));
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

但它给了我一个例外

{Android.Util.AndroidRuntimeException:从Activity上下文外部调用startActivity()需要FLAG_ACTIVITY_NEW_TASK标志.这真的是你想要的吗?在/ Users/...中的System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()[0x0000c]

我该怎么办?

android xamarin.android xamarin xamarin.forms

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

SaveFileDialog在c#中使用streamwriter出现问题

我想从streamwriter中的内容中使用bild保存文件,但是在此代码中

SaveFileDialog savefile = new SaveFileDialog();
                savefile.FileName = "unknown.txt";
                savefile.Filter = "Text files (*.txt)|*.txt|All files (*.*)|*.*|";
                if (savefile.ShowDialog() == DialogResult.OK)
                {
                    using (StreamWriter sw = new StreamWriter(savefile.FileName, false, System.Text.Encoding.Unicode))
                    sw.WriteLine("Test line");
                    sw.WriteLine("Test line2");
                    sw.WriteLine("Test line3");
                }
Run Code Online (Sandbox Code Playgroud)

在行sw.WriteLine("Test line2"); sw.WriteLine("Test line3");,是错误,sw不存在!

但我很少使用代码

using (StreamWriter sw = new StreamWriter("\unknow.txt", false,System.Text.Encoding.Unicode)) sw.WriteLine("Test line"); sw.WriteLine("Test line2"); sw.WriteLine("Test line3");

一切正常!哪里有问题?谢谢 !

c# using

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