<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Test.Views.Activities.ActivityMapList"
xmlns:maps="clr-namespace:Microsoft.Maui.Controls.Maps;assembly=Microsoft.Maui.Controls.Maps"
xmlns:sensors="clr-namespace:Microsoft.Maui.Devices.Sensors;assembly=Microsoft.Maui.Essentials"
xmlns:ios="clr-namespace:Microsoft.Maui.Controls.PlatformConfiguration.iOSSpecific;assembly=Microsoft.Maui.Controls"
ios:Page.UseSafeArea="False"
Shell.NavBarIsVisible="False"
Style="{StaticResource Key=DefaultPage}">
<ContentPage.Content>
<StackLayout>
<maps:Map
VerticalOptions="FillAndExpand"
HorizontalOptions="FillAndExpand">
<x:Arguments>
<MapSpan>
<x:Arguments>
<sensors:Location>
<x:Arguments>
<x:Double>36.9628066</x:Double>
<x:Double>-122.0194722</x:Double>
</x:Arguments>
</sensors:Location>
<x:Double>0.01</x:Double>
<x:Double>0.01</x:Double>
</x:Arguments>
</MapSpan>
</x:Arguments>
</maps:Map>
</StackLayout>
</ContentPage.Content>
</ContentPage>
Run Code Online (Sandbox Code Playgroud)
(https://i.stack.imgur.com/7CBIp.jpg)
StackLayout 或 Grid 内的地图控件,iOS 的 SafeArea 为 false,如图所示。你有什么解决办法吗?
(https://i.stack.imgur.com/q0TjO.jpg)
我需要在地图上使用网格或堆栈布局
我想在现有的 Android 和 iOS 项目中使用 .NET MAUI,但我不确定是否需要将 UseMauiEssentials 和 UseMaui 添加到我现有的 csproj 文件中,还是仅添加其中之一。目前,我在 Android 和 iOS 项目中使用 Xamarin.Essentials 和其他一些 Xamarin NuGet 包。
我的 Android csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-android</TargetFramework>
<SupportedOSPlatformVersion>23</SupportedOSPlatformVersion>
<OutputType>Exe</OutputType>
<ApplicationId>com.companyname.AndroidprojectwithXamarin</ApplicationId>
<ApplicationVersion>1</ApplicationVersion>
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MonoGame.Content.Builder.Task" Version="3.8.1.303" />
<PackageReference Include="MonoGame.Framework.Android" Version="3.8.1.303" />
<PackageReference Include="Xamarin.Essentials" Version="1.7.4" />
</ItemGroup>
<Target Name="RestoreDotnetTools" BeforeTargets="Restore">
<Message Text="Restoring dotnet tools" Importance="High" />
<Exec Command="dotnet tool restore" />
</Target>
</Project>
Run Code Online (Sandbox Code Playgroud)
我的 iOS csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0-ios</TargetFramework>
<OutputType>Exe</OutputType>
<SupportedOSPlatformVersion>15.0</SupportedOSPlatformVersion>
<CodesignKey>iPhone Developer</CodesignKey>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' …Run Code Online (Sandbox Code Playgroud) 我创建了一个名为 的模型类Project,还创建了一个名为 的 ViewModel 类MainPageViewModel。
我想要实现的是一个具有多列的简单表。应该有一个名为“操作”的列,并且该列应该有一个按钮。
这是 XAML:
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="SharpTool.UI.MainPage"
xmlns:viewmodel="clr-namespace:SharpTool.UI.ViewModels"
xmlns:models ="clr-namespace:SharpTool.UI.Models"
x:DataType="viewmodel:MainPageViewModel">
<ScrollView>
<VerticalStackLayout
Padding="10, 10">
<Border MinimumHeightRequest="50" StrokeThickness ="0.5">
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
<Border StrokeThickness="0.1" Grid.Column="0">
<Label HorizontalOptions="Center" VerticalOptions="Center" FontFamily="icon" FontSize="15" Text="Id" TextColor="Blue"/>
</Border>
<Border StrokeThickness="0.1" Grid.Column="1">
<Label HorizontalOptions="Center" VerticalOptions="Center" FontFamily="icon" FontSize="15" Text="Name" TextColor="Blue"/>
</Border>
<Border StrokeThickness="0.1" Grid.Column="2">
<Label HorizontalOptions="Center" VerticalOptions="Center" FontFamily="icon" FontSize="15" Text="Discription" TextColor="Blue"/>
</Border>
<Border …Run Code Online (Sandbox Code Playgroud) 我想我对异步等待模型的理解一定遗漏了一些东西。本来应该很简单的事情似乎很难实现。
我有一个用户界面,需要检查用户是否已登录。为此,我需要在我的一个类中调用一个方法来执行一些查询。
此类依次调用仅具有异步方法的第 3 方代码。
我如何调用该异步方法并使应用程序等待,直到我得到结果?
我已经尝试了所有建议的东西,例如ConfigureAwait,,,等等。似乎没有什么可以可靠地工作。RunSynchronous.Result
看起来很愚蠢,这样的事情是如此困难,所以我认为我错过了一条关键信息。
谢谢。
如何在搜索栏上设置边框半径?
我已经尝试了很多方法来更改此设置(例如,尝试显式指定标签 <Border>),但搜索栏中没有与此属性关联的标签。
我在我的 dotnet MAUI 应用程序上遇到了一个奇怪的问题,它对我来说非常有用,除了一个人的 OnePlus 之外,该问题不适用于任何其他手机。
我无法弄清楚,并且我没有看到网上发布的任何其他问题
除了重新制作整个应用程序之外,我不知道还能尝试什么
当我从 Xamarin.Forms 转换时,我正在尝试对 .NET Maui 中的 svg 图像进行动态着色。我设置了以下代码以使用字符串格式的颜色绑定,但抛出以下错误。关于如何在 .NET Maui 中实现这一目标有什么想法吗?
错误 XLS0503 类型“IconTintColorBehavior”的值无法添加到类型“IList`1”的集合或字典中
XAML代码
<Grid>
<Image
x:Name="NeedleSVG"
WidthRequest="200"
HeightRequest="200"
Source="resource://XamarinAttributeProgrammer.Resources.Images.Needle.svg">
<Image.Effects>
<mct:IconTintColorBehavior TintColor="{Binding NeedleColorInHex}" />
</Image.Effects>
</Image>
<Image
WidthRequest="200"
HeightRequest="200"
Source="resource://XamarinAttributeProgrammer.Resources.Images.Backlight.svg">
<Image.Effects>
<mct:IconTintColorBehavior TintColor="{Binding BackColorInHex}" />
</Image.Effects>
</Image>
<Image
WidthRequest="200"
HeightRequest="200"
Source="resource://XamarinAttributeProgrammer.Resources.Images.Housing.svg">
<Image.Effects>
<mct:IconTintColorBehavior TintColor="{Binding BackColorInHex}" />
</Image.Effects>
</Image>
<Button ClassId="BackLight"
BackgroundColor="Transparent"
WidthRequest="250"
HorizontalOptions="Center"
Clicked="OnPreviewTapped"/>
<Button ClassId="Needle"
BackgroundColor="Transparent"
HeightRequest="80"
WidthRequest="80"
VerticalOptions="Center"
HorizontalOptions="Center"
Margin="0,20,0,0"
Clicked="OnPreviewTapped"/>
</Grid>
Run Code Online (Sandbox Code Playgroud)
查看模型
public string SelectedColorInHex
{
get
{
NotifyGaugeOfChangeAsync();
Task.Delay(50).Wait(); // wait 50ms so that …Run Code Online (Sandbox Code Playgroud) 我们有一个适用于 .NET Core 7 MAUI Android 应用程序的现有 Azure DevOps 构建管道,该管道直到今天(2023 年 11 月 20 日)都运行良好。我们注意到之前的成功构建使用的是 MSBuild 版本 17.7.3。今天它使用的是 17.8.3,我认为这意味着它位于带有新 VS 映像的服务器上。
MSBuild version 17.8.3+195e7f5a3 for .NET
Build FAILED.
C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\33.0.95\targets\Microsoft.Android.Sdk.Tooling.targets(20,5): error XA0031: Java SDK 11.0 or above is required when using .NET 6 or higher. Download the latest JDK at: https://aka.ms/msopenjdk`
Run Code Online (Sandbox Code Playgroud)
global.json如果您正在为 NET 7 构建而没有在文件中明确说明(该dotnet build步骤明确说明了 Framework -f net7.0-android),那么这似乎是 Visual Studio 2022 17.8.3 中 Xamarin / MAUI 构建的重大更改。