xamarin 相关问题

Xamarin是一个由Xamarin.iOS,Xamarin.Android,Xamarin.Mac和Xamarin Test Cloud组成的平台。它允许您编写适用于iOS,Android和Mac的跨平台本机应用程序,并在整个生命周期内关注您的应用程序。 Xamarin.Forms的引入支持iOS,Android和Windows的Native UI开发

.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

如何限制用户在xamarin中选择相机应用程序

我正在 Xamarin 上编写一个项目,我的任务是限制用户从除默认 Android 相机之外的任何应用程序获取照片。我曾尝试使用 ActionImageCapture 打开相机,但有一些

回答 1 投票 0

Visual Studio 2022 管理 nuget 包灰显

我不明白为什么我突然无法管理我的nuget包?有人遇到过这样的问题吗

回答 4 投票 0

Microsoft MAUI:如何在 MAUI 中创建在新窗口中打开的报告?

如何在 MAUI 中创建在新窗口中打开的动态报告?

回答 2 投票 0

使用 MKCreateClusterAnnotation Xamarin Forms 显示集群视图

如何使用 ios 地图渲染对 pin 结果进行分组或聚类? 我尝试了以下逻辑,但我在实现中感到困惑。 https://github.com/xamarin/ios-samples/blob/main/ios11/MapKitS...

回答 1 投票 0

Xamarin.Android 应用程序关闭时调用函数

我想从 Xamarin.Android 项目中的 MainActivity.cs 调用函数。 我需要在我的应用程序关闭后调用我的函数,而不是在应用程序窗口隐藏时调用我的函数。当我尝试使用 OnSt 时...

回答 1 投票 0

xamarin.android 应用程序关闭时调用 void

我想从 xamarin.android 项目中的 mainactivity.cs 调用函数。 我需要在我的应用程序关闭后调用我的函数,而不是在应用程序窗口隐藏时调用我的函数。当我尝试使用 OnSt 时...

回答 1 投票 0

将 Xamarin 应用程序移植到毛伊岛。很少发生启动崩溃。 (不超过五分之一)

似乎在GC线程上。 (单原) mono sgen 正在调用 CryptoNative_HmacUpdate,然后运行一些 java,然后在 libcrypto.so 中调用 HMAC_Update(这是一个本机 android lib,例如...

回答 1 投票 0

如何将 XAML(或另一个 ContentView)作为子项传递给 ContentView

我正在尝试创建一个 ContentView,并在其中将子项作为 XAML 或(另一个内容视图)传递。我怎样才能做到这一点? 例如。: 我有一种观点说 Header.xaml 我正在尝试创建一个 ContentView,并在其中将子项作为 XAML 或(另一个内容视图)传递。我怎样才能做到这一点? 例如: 我有一种观点是 Header.xaml <?xml version="1.0" encoding="utf-8" ?> <ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:strings="clr-namespace:Eurynote.Localization.Resources.en;assembly=Eurynote.Localization" x:Class="Eurynote.Core.Views.Common.EurynoteHeader"> <HorizontalStackLayout Spacing="10" VerticalOptions="Center"> <Image Source="brand_icon" WidthRequest="32" HeightRequest="30" /> <Label Text="Header" Margin="0,-3,0,0" /> </HorizontalStackLayout> </ContentView> 现在,在我的 MainPage.xaml 文件中,我可以将此视图称为 <common:Header /> 并且运行良好。 但是我如何将另一个控件传递到与子项相同的内容视图,例如按钮、标签等...或任何其他 ContentView,如下面两个示例所示。 <common:Header> <Button Text="Button" /> </common:Header> <common:Header> <common:AnotherView /> </common:Header> 我想确保只能传递单个内容,如Frame。 谢谢你!!! 首先,如果使用以下代码,ContentView的内容将被Button覆盖。 <common:Header> <Button Text="Button" /> </common:Header> 因此您无法从 xaml 中为 contentview 添加子项。但你可以在后面的代码中做到这一点。如: 在xaml中: <common:Header x:Name = "header"> 在页面的构造函数中: public partial class MainPage() { InitializeComponent(); var layout = head.Content as HorizontalStackLayout; layout.Children.Add(new Button(){ Text = "new button"}); } 您可以通过这种方式将新项目作为子项添加到内容视图中。

回答 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

.NET Maui 条目已完成,iOS 上没有返回按钮?

我正在使用输入控件(.Net 7),键盘类型专门设置为数字,因为不需要输入字母文本,并且会导致问题,因为它将数据发送到 BT 设备并且是

回答 1 投票 0

在Xamarin中调试时,不会在断点处停止

我正在使用 Visual Studio 2022 Community、Xamarin.Forms 和 Android 的组合来开发一个应用程序。 在调试模式下,我放置了断点,但它们不会停止。 有什么需要我做的吗

回答 2 投票 0

如何使用 MAUI .net 8 检查和修复 HotReload?

我无法在 iOS 或 Android 上使用 .net 8 和 MAUI 的 Visual Studio 2022 Mac 上使用热重载。 它在 IDE 设置中启用: 并且在运行时也显示为已连接: 但是当做...

回答 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

在同一个 UIViewController 中第一个 UITableView 的 RowClick 上绑定第二个 UITableView - ios Xamarin

我在同一个 UIViewController 中有两个 UITableView。 tblView1 和 tblView2。 两个 TableView 都动态地提供数据。 现在我的问题是:我想在 tblView2 的基础上加载数据

回答 1 投票 0

SQLite-net-pcl - 始终返回 ID 为 0 (Xamarin)

由于 Android 7.0 SQlite 问题,我最近从 SQLite.NET 迁移到 SQLite-net-pcl。 在此过程中,我更新了所有库,并且在插入/删除等方面一切正常...

回答 6 投票 0

Azure Pipelines iOS 预配配置文件已安装但找不到

我的 Xamarin 应用程序构建管道失败,并显示找不到指定的 iOS 配置文件“”。尽管开发人员证书和配置文件已安装...

回答 1 投票 0

Mono.AndroidTools.AdbException:尝试读取流末尾(在 Visual Studio 上)

我正在使用 Xamarin / Visual studio for Mac 构建应用程序 我已经在 Mac mini 上有一个项目了。 现在我将该项目转移到了新的 iMac 上。 编译就好了。但是当尝试部署到物理上时

回答 5 投票 0

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