xamarin.forms 相关问题

Xamarin.Forms是一款Microsoft产品,允许从单个共享C#代码库为Android,iOS,Windows和其他应用程序构建本机,跨平台应用程序。

在 C# 中将 DataUrl 转换为图像并使用字节写入文件

你好,我的签名是这样的: 它被编码为一个数据 URL,特别是这个字符串: 数据:图像/ png;base64,iVBORw0KGgoAAAANSUhEUgAAAZAAAADICAYAAADGFbfiAAAYlElEQVR4Xu2dC8w1R1nHQSCIgIKVGLmoiLc...

回答 2 投票 0

防止 Xamarin iOS 中的屏幕捕获

我想防止在ios xamarin项目中捕获敏感信息。 我已经有了这个插件,但如果我只想使用 iOS 屏幕保护代码,而不是整体实现它......

回答 1 投票 0

Xamarin:ViewModel 不更新 UI

我第一次尝试实现 ViewModel 绑定,发现绑定到视图模型中的属性的标签没有更新以反映该值 我希望这是...

回答 1 投票 0

VS 2022 Xamarin.Forms Firebase 云消息传递工作示例

尝试将推送通知添加到我的 Xamarin.Forms 应用程序,但找不到任何实施 Firebase 云消息传递的工作示例。 我的意思是,所有示例/教程中没有一个可以工作的示例......

回答 2 投票 0

Xamarin.Forms 中的EventToCommandBehaviorrelativeSource

为什么不起作用? 为什么不起作用? <Editor Text="{Binding OptionText}"> <Editor.Behaviors> <xct:EventToCommandBehavior EventName="Focused" Command="{Binding CheckEditorViewCommand,Source={RelativeSource AncestorType={x:Type view:SurveyViewModel}}}" /> </Editor.Behaviors> </Editor> 当我尝试使用此 xaml 代码打开页面时,应用程序崩溃。 01-14 07:50:43.611 F/mono-rt (28519): [错误] 致命未处理 异常:System.InvalidOperationException:操作无效 由于对象的当前状态。 01-14 07:50:43.611 F/单声道 (28519):在 Xamarin.Forms.Binding.ApplyRelativeSourceBinding (Xamarin.Forms.BindableObject 目标对象, Xamarin.Forms.BindableProperty targetProperty) [0x00041] 在 D: \s\Xamarin.Forms.Core\Binding.cs:158 01-14 07:50:43.611 F/mono-rt (28519):位于 System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__7_0 (System.Object 状态) [0x00000] 中 /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021 01-14 07:50:43.611 F/mono-rt (28519): 在 Android.App.SyncContext+<>c__DisplayClass2_0.b__0 () [0x00000] 在 /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.App/SyncContext.cs:36 01-14 07:50:43.611 F/mono-rt (28519): 在 Java.Lang.Thread+RunnableImplementor.Run()[0x00008]中 /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Java.Lang/Thread.cs:36 01-14 07:50:43.611 F/mono-rt (28519): 在 Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] 中 /Users/runner/work/1/s/xamarin-android/src/Mono.Android/obj/Release/monoandroid10/android-33/mcw/Java.Lang.IRunnable.cs:84 01-14 07:50:43.611 F/mono-rt (28519): 在 Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V (_JniMarshal_PP_V 回调、System.IntPtr jnienv、System.IntPtr klazz) [0x00005] 在 /Users/runner/work/1/s/xamarin-android/src/Mono.Android/Android.Runtime/JNINativeWrapper.g.cs:22 01-14 07:50:43.611 F/mono-rt (28519): at (包装器本机到托管) Android.Runtime.JNINativeWrapper.Wrap_JniMarshal_PP_V(intptr,intptr) 当我放下这是鳕鱼时,页面就会工作。 我已经以绑定方式理解了这个问题,但我不明白如何正确执行。 我用这种绑定方法解决了我的问题: <Editor Text="{Binding OptionText}"> <Editor.Behaviors> <xct:EventToCommandBehavior EventName="TextChanged" CommandParameter="{Binding .}" Command="{Binding Source={x:Reference Name=SurveyPageCustomName}, Path=BindingContext.CheckEditorViewCommand}" /> </Editor.Behaviors> </Editor> 我不知道为什么,但这Command="{Binding CheckEditorViewCommand,Source={RelativeSource AncestorType={x:Type view:SurveyViewModel}}}"不适用于行为,但适用于TapGestureRecognizer。这让我很困惑。

回答 1 投票 0

如何在xamarin表单中显示进度条通知

我正在使用 xamarin 表单,我遇到了这个插件 https://github.com/thudugala/Plugin.LocalNotification 以便向用户显示通知。但是如何才能在通知上显示进度条...

回答 2 投票 0

在属性面板中找不到构建操作 - Xamarin Forms

正在使用 Visual Studio 2022 的 Xamarin 表单构建应用程序,我想嵌入位于可绘制文件夹中的汽车图像资源,但当我选择...时,构建操作不会出现在其属性中

回答 1 投票 0

MAUI - ResourceManager.GetString 引发异常 System.IO.FileNotFoundException

我已将Xamarin应用程序的代码移植到.NET MAUI应用程序。没有编译错误,因此我尝试运行该应用程序并检查它最初的工作情况。不幸的是我得到了 System.IO。

回答 1 投票 0

Xamarin - 从外部 ViewModel 调用控制器方法

我对Xamarin不太熟悉,我不知道如何解决我当前的情况,简而言之,我不知道如何从控制器外部调用我的方法SaveSignature - 下面有...

回答 2 投票 0

Xamarin 表单:如何获取 Wifi MAC 地址

我试图通过代码获取我正在登录的设备的MAC地址WIFI,但无法做到。 我们已经给仓库里的工人提供了设备,但他们不断更换和丢失设备,...

回答 1 投票 0

xamarin 形式:已抛出 System.ArgumentNullException (IOS)

我正在使用 webview 来解析我的 HTML 数据。为此,我使用自定义渲染。 在主项目中: 公共类 MyWebView :WebView { 公共静态只读 BindableProperty UrlProperty =

回答 3 投票 0

Android 应用程序关闭时如何从 firebase 获取 PushNotifications

不久前我开始学习FCM,我在YouTube上查看了教程 https://www.youtube.com/watch?v=7w2q2D6mR7g (描述中有 GitHub 链接)。这个 Android 应用程序和通知...

回答 1 投票 0

.NET MAUI 中的 Shell 背景渐变

知道如何为 Shell 提供渐变背景吗? 我尝试在 Shell 背景上定义 LinearGradientBrush 但这不起作用。 知道如何为 Shell 提供渐变背景吗? 我尝试在 Shell 背景上定义 LinearGradientBrush,但这不起作用。 <?xml version="1.0" encoding="UTF-8" ?> <Shell xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"> <Shell.Background> <LinearGradientBrush StartPoint="0,0" EndPoint="1,0"> <GradientStop Color="Yellow" Offset="0.0" /> <GradientStop Color="Red" Offset="0.25" /> <GradientStop Color="Blue" Offset="0.75" /> <GradientStop Color="LimeGreen" Offset="1.0" /> </LinearGradientBrush> </Shell.Background> <FlyoutItem FlyoutDisplayOptions="AsMultipleItems"> <!-- FlyoutItem contents here --> </FlyoutItem> </Shell> 我已经确认这是为 Shell.Background 设置渐变时的已知问题,请参阅 Shell.Background - Gradient does not work #10445,您可以按照该线程进行操作。 幸运的是,您可以单独设置渐变背景。如果您有“外壳”弹出窗口,则可以为“外壳”弹出项目设置渐变背景: <Shell.FlyoutBackground> <LinearGradientBrush StartPoint="0,0" EndPoint="1,0"> <GradientStop Color="Yellow" Offset="0.0" /> <GradientStop Color="Red" Offset="0.25" /> <GradientStop Color="Blue" Offset="0.75" /> <GradientStop Color="LimeGreen" Offset="1.0" /> </LinearGradientBrush> </Shell.FlyoutBackground> 另外,如果要将 ShellContent 背景设置为渐变背景,可以将渐变背景添加到 ContentPage 的背景属性中。 <ContentPage.Background> <LinearGradientBrush StartPoint="0,0" EndPoint="1,0"> <GradientStop Color="Yellow" Offset="0.0" /> <GradientStop Color="Red" Offset="0.25" /> <GradientStop Color="Blue" Offset="0.75" /> <GradientStop Color="LimeGreen" Offset="1.0" /> </LinearGradientBrush> </ContentPage.Background> 希望这有帮助!

回答 1 投票 0

清除应用程序内存/取消注册服务/在应用程序内重新登录

我不知道如何描述标题,抱歉。 我正在使用 .net 毛伊岛。 我面临的问题很难解释,所以我会添加尽可能多的代码,希望能解决这个问题......

回答 1 投票 0

如何使用 Xamarin 立即用点屏蔽密码字符

我想消除在 Xamarin.Forms 中输入密码时的延迟。我在互联网上没有找到任何解决方案。 我想消除在 Xamarin.Forms 中输入密码时的延迟。我在网上没有找到任何解决方案。 <local:NoDelayEntry x:Name="passwordEntry" Placeholder="Password" /> class NoDelayEntry : Entry { public NoDelayEntry() : base() { this.TextChanged += OnEntryTextChanged; } private void OnEntryTextChanged(object sender, TextChangedEventArgs e) { // Customize the behavior as needed this.IsPassword = true; this.Text = new string('●', e.NewTextValue.Length); } } 到目前为止我已经尝试过以下操作;但是,当我登录时,原始密码文本被替换为“●”。有没有办法在保留原始密码的同时仍然使用屏蔽行为? 一种想法是使用一个标签来遮盖密码字段,该标签会更新以显示键入的点数,但我不确定如何保持标签下方的密码字段可选。

回答 1 投票 0

如何在 Xamarin Forms 中缩放 WebView?

我无法缩放 Xamarin.Forms 中的 Web 视图。下面是代码,请有人帮助我。谢谢 我无法缩放 Xamarin.Forms 中的 Web 视图。下面是代码,请有人帮助我。谢谢你 <ContentPage xmlns="http://xamarin.com/schemas/2014/forms" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" x:Class="highchart.MainPage"> <ScrollView> <WebView VerticalOptions="FillAndExpand" WidthRequest="80" HorizontalOptions="FillAndExpand"> <WebView.Source WebView.EnableZoomControls="true" WebView.ScalesPageToFit = "true"> <HtmlWebViewSource x:Name="HighChart"/> </WebView.Source> </WebView> </ScrollView> </ContentPage> 针对 Android 特定(在共享项目 [FORMS] 内) XAML 解决方案: <ContentPage ... xmlns:android="clr-namespace:Xamarin.Forms.PlatformConfiguration.AndroidSpecific;assembly=Xamarin.Forms.Core"> <WebView Source="https://www.xamarin.com" android:WebView.EnableZoomControls="true" android:WebView.DisplayZoomControls="true" /> C# 解决方案: using Xamarin.Forms.PlatformConfiguration; using Xamarin.Forms.PlatformConfiguration.AndroidSpecific; ... WebView.On<Android>().EnableZoomControls(true); WebView.On<Android>().DisplayZoomControls(true); 我在iOS上的Android上测试过,看来这个问题只出现在Android上。 您可以创建一个自定义渲染器来实现缩放功能,它在我这边工作得很好。 [assembly: ExportRenderer(typeof(WebView), typeof(CustomWebViewRenderer))] namespace PDFPOC.Droid { public class CustomWebViewRenderer : WebViewRenderer { public CustomWebViewRenderer(Context context) : base(context) { } protected override void OnElementChanged(ElementChangedEventArgs<WebView> e) { base.OnElementChanged(e); if (e.NewElement != null) { Control.Settings.AllowUniversalAccessFromFileURLs = true; Control.Settings.SetSupportZoom(true); Control.Settings.BuiltInZoomControls = true; Control.Settings.DisplayZoomControls = true; } } } }

回答 2 投票 0

ListView 内容未出现 - Xamarin Forms

我试图显示周列表,每周可以有多个事件和恢复(GroupedWeeksModel 类)。问题是中的内容没有出现,...

回答 1 投票 0

.NET MAUI CollectionView SwipeView 更改 TextColor

所以我将 SwipeView 与 .NET MAUI 的 CollectionView 结合使用,我想知道如何更改 TextColor。 所以我将 SwipeView 与 .NET MAUI 的 CollectionView 结合使用,我想知道如何更改 TextColor。 <SwipeView.RightItems> <SwipeItems> <SwipeItem BackgroundColor="LightGray" IconImageSource="Icon.png" Text="Unread"/> </SwipeItems> </SwipeView.RightItems> 我似乎无法找到直接的方法,我是否需要以某种方式本地执行此操作? 如果是的话有人可以指导我吗? 您可以使用SwipeItemView来实现: <CollectionView ...> <CollectionView.ItemTemplate> <DataTemplate > <SwipeView> <SwipeView.RightItems> <SwipeItems> <SwipeItemView> <StackLayout BackgroundColor="red"> <Label Text="Delete" TextColor="Aqua"/> </StackLayout> </SwipeItemView> <SwipeItemView> ... </SwipeItemView> </SwipeItems> </SwipeView.RightItems> <HorizontalStackLayout Padding="2"> <Label Text="{Binding ...}"/> <Label Padding="50,0,0,0" Text="{Binding ...}"/> </HorizontalStackLayout> </SwipeView> </DataTemplate> </CollectionView.ItemTemplate> </CollectionView> 有关更多信息,您可以参考文档:自定义刷卡项目。

回答 1 投票 0

XAML > ViewModel 命令参数 - 无法从对象转换为布尔值?

我有这个XAML 我有这个XAML <Label.GestureRecognizers> <TapGestureRecognizer Command="{Binding TapGestureForUpdateCategories, Source={x:Reference MainPage}}" CommandParameter="false" /> </Label.GestureRecognizers> 以及我的 ViewModel 中的这段代码 public Command TapGestureForUpdateCategories => new Command(val => { App.DB.UpdateAllCategoryGroups(val); App.DB.UpdateAllCategory(val); }); 我试图从 XAML 传递参数 true 或 false,但在命令 C# 代码中,val 下有一行显示“无法从对象转换为 bool”。谁能帮我解决这个问题吗? 修改如下,我们可以通过TapGestureRecognizer.CommandParameter里面的x:type定义我们想要的类型 <Label.GestureRecognizers> <TapGestureRecognizer Command="{Binding TapGestureForUpdateCategories, Source={x:Reference MainPage}}"> <TapGestureRecognizer.CommandParameter> <x:Boolean>True</x:Boolean> </TapGestureRecognizer.CommandParameter> </TapGestureRecognizer> </Label.GestureRecognizers> 你可以使用这个方法

回答 2 投票 0

Maui:CreateMauiApp 之外的 AddHttpClient 和 AddSingleton

我正在使用 Prism 和 DryIoc 将应用程序从 Xamarin Forms 迁移到 Maui,并且需要在 CreateMauiApp 函数之外注册服务和 HttpClientFactory(原因是我不知道最终结果...

回答 1 投票 0

© www.soinside.com 2019 - 2024. All rights reserved.