我有一个 Visual Studio 2022 (17.4.3) 解决方案。
我正在将 Xamarin 应用程序迁移到毛伊岛。
我收到两个构建错误:
APT2144 invalid file path 'C:\...\obj\Debug\net6.0-android\res\resources\styles\styles.xaml'
APT2144 invalid file path 'C:\...\obj\Debug\net6.0-android\res\resources\styles\colors.xaml'
Run Code Online (Sandbox Code Playgroud)
这些文件作为 app assembly/Resources/Styles/Colors.xaml 和 Styles.xaml 存在。
我需要一些帮助来了解Visual Studio 中BaseSize的参数MauiImage以及导入缩放到不同屏幕密度的图像所需的过程,可能还需要一些有关移动设备上图像密度缩放的基础知识。
假设我有一个宽度为 380px、高度为 168px 的 PNG 图像,如下所示。
文档说:
可以通过将 BaseSize 属性设置为可被 8 整除的值来指定图像的基本尺寸:
那么...我现在该怎么办?380px 不能被 8 整除。我是否将宽度更改为 384 或 376 BaseSize="376,168"?生成的图像是否会被裁剪 4 个像素?或者这里正确的解决方案是什么?
BaseSize 属性的值表示图像的基线密度,并且实际上是图像的 1.0 比例因子(通常在代码中用于指定图像大小的大小),所有其他密度大小均从中派生。该值将用于确保图像正确调整大小以适应不同的显示密度。如果您没有为位图图像指定 BaseSize,则不会调整图像的大小。
我正在 Android 上构建,此页面显示 Android 基线密度是 160dpi 或mdpi.
那么...这是否意味着 MAUI 自动为 ldpi、hdpi、xhdpi、xxhdpi、xxxhdpi 创建图像?
但是......这是否意味着图像会在更高的屏幕密度上变得像素化?
如果将上面的图像定义为最高屏幕密度,然后在不损失质量的情况下缩小到较低密度,不是更有意义吗?
在我今天将 Visual Studio 更新到 17.5.1 之前,这一直有效(我之前使用的是 17.4)。更新后,我的 Mac 将显示在 Visual Studio 中,但在尝试连接后显示主机无法访问。我能够使用主机名和 IP 地址通过 ssh 连接到 Mac,并成功运行远程命令,例如 ssh jtest@m-1 'ls'。它似乎与这个问题类似:SSH Connection issues,我尝试了其中的所有内容 - 但它仍然说主机无法访问。MAC操作系统版本为13.2.1。
我有一个类“CellularInfo”,我试图在可观察集合中显示项目,但Rssi、Rsrp、 和的绑定Rsrq未显示。
我知道 LTEInfo 正在 CellularInfo.xaml.cs 中填充,但它没有绑定。
蜂窝信息.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"
xmlns:local="clr-namespace:CellularSignal1"
x:Class="CellularSignal1.CellularInfo"
Title="Signal">
<VerticalStackLayout>
<ListView BackgroundColor="Red" ItemsSource="{x:Reference lteStrengths}">
<ListView.ItemTemplate>
<DataTemplate>
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<Label Grid.Row="0" Text="{Binding Rssi}" HeightRequest="50"/>
<Label Grid.Row="1" Text="{Binding Rsrp}" HeightRequest="50"/>
<Label Grid.Row="2" Text="{Binding Rsrq}" HeightRequest="50"/>
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</VerticalStackLayout>
</ContentPage>
Run Code Online (Sandbox Code Playgroud)
CellularInfo.xaml.cs:
namespace CellularSignal1;
using Android.Content;
using Android.OS;
using Android.Telephony;
using Java.Util.Logging;
using Microsoft.Maui.Controls;
using Microsoft.Maui.Controls.Internals;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
public …Run Code Online (Sandbox Code Playgroud) 当我尝试导航到多层导航时,后退按钮不起作用。
假设首先进入“仪表板”页面,然后进入“动物”页面,然后如果我尝试后退按钮,它工作正常,但如果我深入“猫”页面,然后尝试后退按钮,它就不起作用。我检查了 Windows 和 Android 设备。
1.<ShellContent Title="Home" ContentTemplate="{DataTemplate page:DashBoard}" Route="DashBoard" />
2.await Shell.Current.GoToAsync("animals");
3.await Shell.Current.GoToAsync("cats");
我在这里缺少什么吗,请帮助我。
我有一个 MAUI 应用程序,我想创建 APK 文件来分发它,我不想在商店中发布它。
我已经尝试过这个:
唯一的保存选项是 .aac 文件,但我想要 .apk 文件。
如何编译 .apk 文件?
谢谢。
在我的 .NET MAUI 条目中,我想更改代码隐藏中条目中下划线的颜色。
有没有办法做到这一点?
======= 编辑并实施下面的答案 ======
提示:我使用自己的 BorderlessEntryControl 尝试了下面的答案,该控件派生自 Entry Control。在那里,至少 Placehodler-TextColor 丢失了。也许还有更多属性
前
后
我正在开发一个.Net Maui应用程序,并面临集合视图的问题,更具体地说是列表视图,即使我尝试通过替换列表视图来尝试可绑定布局(如堆栈布局),问题仍然存在。
只能点击前几个项目。当我调试时,代码隐藏中的函数甚至命令(在视图模型中)都不会被触发。
对于点击项目,我使用列表视图的单击事件和可绑定布局的手势识别器。点击该项目后,我需要转到详细信息页面。所有项目的行为应该相同,而不是前几个项目。
通过在边框内添加可绑定布局,Android 上的问题得到解决,但 IOS 上的问题仍然存在。
参考如下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="MobileApp_MAUI.Views.Support.SupportPage"
xmlns:model="clr-namespace:MobileApp_MAUI.Model"
xmlns:viewmodel="clr-namespace:MobileApp_MAUI.ViewModel"
xmlns:itemtemplate="clr-namespace:MobileApp_MAUI.Views.ContactUs.Templates"
x:DataType="viewmodel:SupportPageViewModel"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit"
Title="Support">
<ScrollView VerticalScrollBarVisibility="Never" HorizontalScrollBarVisibility="Never" Grid.Row="0" VerticalOptions="FillAndExpand">
<StackLayout BackgroundColor="#f5f2ed">
<!--MAIN HEADER-->
<Grid BackgroundColor="{StaticResource XBlue}" Margin="0,0,0,10">
<Grid.RowDefinitions>
<RowDefinition Height="180" />
</Grid.RowDefinitions>
<Label Text="You can browse the frequently asked questions using the search bar or browse by clicking the topic buttons below. If you cannot find the answer to your question please contact us."
LineBreakMode="WordWrap"
HorizontalOptions="Center"
VerticalOptions="Center" BackgroundColor="#004A4A"
Padding="20,25,20,25" TextColor="White" …Run Code Online (Sandbox Code Playgroud) xamarin.android xamarin maui maui-community-toolkit .net-maui.shell
我目前正在使用 .NET MAUI 开发应用程序,但遇到了无法解决的问题。我在调试的时候,在android平台上导航页面时,遇到了一个奇怪的异常
\n该应用程序有两个选项卡:主页和自助。登录后,用户将进入“主页”选项卡。但是,当我尝试从主页导航到任何其他页面时,应用程序会抛出以下错误并随后崩溃:
\n\n\n无法访问已处置的对象。\n对象名称: \xe2\x80\x98Microsoft.Maui.Platform.ContentViewGroup\'
\n
这是我的 xaml 代码:
\n<?xml version="1.0" encoding="utf-8" ?>\n<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"\n xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"\n x:Class="Views.Dashboard.HomePageDashboard"\n Title="HomePageDashboard">\n\n<Shell.TitleView>\n <Grid>\n <Grid.RowDefinitions>\n <RowDefinition Height="*" />\n </Grid.RowDefinitions>\n <Grid.ColumnDefinitions>\n <ColumnDefinition Width="9*" />\n <ColumnDefinition Width="*" />\n </Grid.ColumnDefinitions>\n <Frame \n \n Grid.Column="1"\n HeightRequest="40"\n WidthRequest="40"\n CornerRadius="20"\n BackgroundColor="Transparent"\n HorizontalOptions="Center"\n VerticalOptions="Center"\n IsClippedToBounds="True"\n Padding="0"\n >\n <Border BackgroundColor="{StaticResource PrimaryColorLight}">\n <Label Text="{Binding ProfileImageLabel}" TextColor="White" FontSize="Micro" LineBreakMode="WordWrap" HorizontalOptions="Center" VerticalOptions="Center"/>\n <Border.GestureRecognizers>\n <TapGestureRecognizer Command="{Binding GotoProfileCommand}"/>\n </Border.GestureRecognizers>\n </Border>\n </Frame>\n </Grid>\n\n </Shell.TitleView>\n <VerticalStackLayout Margin="0,30,0,0">\n <Label Text="Categories" FontSize="Subtitle" FontAttributes="Bold" FontFamily="Bold" HorizontalOptions="Start" VerticalOptions="Start" …Run Code Online (Sandbox Code Playgroud) 我了解到,到今年年底(2021 年 11 月),微软将不再支持 Xamarin,转而支持 MAUI,而 .NET MAUI 也是下一代 Xamarin Forms,那么 Xamarin.Native 应用程序会发生什么。它们是否也会升级到 MAUI,或者更改只会对 Xamarin Forms 产生影响,但如果对 Xamarin Native 应用程序产生影响,那么我们是否需要将现有应用程序的完整结构更改为 MAUI 框架。请这方面的指导。