xamarin.forms 相关问题

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

UWP 发布输出始终位于测试文件夹中

为什么即使我将 Visual Studio 中的构建设置设置为“发布”,我在侧面加载的 UWP 发行版中创建的所有内容都会放置在末尾带有 _test 的文件夹中?是吗

回答 2 投票 0

无法清除 Xamarin.Forms Android 中的应用程序缓存

我正在尝试清除/删除我的 Xamarin.forms Android 应用程序的应用程序缓存文件夹。我尝试了不同的代码,但该文件夹仍未被清除。 我做了什么 我通过

回答 1 投票 0

如何根据Xamarin表单中collectionView中的值更改行背景颜色

我想根据日期更改collectionView中背景行的颜色。 例如: foreach(myList 中的 var 项目) { if (item.ExpiryDate <= DateTime.Now ) { Mylistrow.

回答 1 投票 0

Xamarin Android 内存使用情况

我正在考虑 Xamarin Android 应用程序,实际上我想在我自己的/物理设备上运行我的 Android 应用程序,其中只包含一个轮播页面,所以,这个应用程序在我的中需要多少内存......

回答 1 投票 0

是否可以在日历视图中用某种颜色或某种方式永久标记过去的某一天

我有一个简单的Android应用程序,它每天通过预定的本地通知提醒我喝水。为此,我使用 AlarmManager 和 BroadcastRreceiver。然而,通过点击...

回答 2 投票 0

如何在 Xamarin Forms 中集成 Apple Pay?

我正在使用xamarin Forms开发应用程序。现在,我需要集成 Apple Pay 我试图通过互联网查找内容,但无法找到有效的解决方案。有人可以建议我吗...

回答 2 投票 0

Xamarin Forms 自定义地图图钉

在我正在开发的应用程序之一中,我需要使用自定义地图图钉,并且我已按照 Xamarin https://developer.xamarin.com/guides/xamarin-forms/application-fundamentals/ 上的指南进行操作定制撕裂...

回答 2 投票 0

xamarin 中的视频播放器旋转(Android)

我是来自 xamarin 社区工具包 (https://learn.microsoft.com/en-us/xamarin/community-toolkit/) 的 usn MediaElement,我需要旋转它。我试图做到这一点只是改变旋转属性......

回答 1 投票 0

Xamarin.Forms 崩溃报告和分析建议/建议

我们在 Xamarin.Forms 中进行开发,如果有人有 Xamarin.Forms 分析和崩溃报告的经验/建议,我很感兴趣,我们也最好支持 iOS、Android 和 UWP。 我

回答 2 投票 0

毛伊岛/表格:有没有办法像富国银行应用程序的货币字段那样获得所需的效果

基本上,在 Maui/Forms 中使用条目,当我输入时,字段应该从右到左填充。我尝试设置 FlowDirection、TextChanged 事件处理程序,但似乎没有任何效果。不确定...

回答 1 投票 0

Xamarin 表单:根据字符数增加编辑器高度

我的 xamarin 表单项目中有一个如下所示的编辑器。 当我在上面输入消息时,我需要根据字符数增加编辑器的高度。 这是我的完整代码...

回答 2 投票 0

为什么 .NET-Maui 全局样式不起作用?

我已经在 .Net Maui 中声明了全局样式并尝试从其中一个页面访问它,但它抛出异常 Microsoft.Maui.Controls.Xaml.XamlParseException:位置 10:37。类型转换器

回答 3 投票 0

Xamarin:我可以在播放视频时将应用程序静音而背景音乐不会停止吗?

在将我们的 xamarin 应用程序迁移到 MAUI 之前的最后几周,我们的客户提出了一个非常“重要”的改进。目前,当我们在应用程序中播放视频时,背景音乐

回答 1 投票 0

在 ValueConverter 中获取 NullReferenceException

我有以下IValueConverter,StringCaseConverter.cs: 内部密封类 StringCaseConverter : IValueConverter { 公共 bool IsUpperCase { 私有获取;放; } 公共对象Conv...

回答 2 投票 0

带有 Xamarin Forms 中 XAML 元素参数的构造函数

是否可以使用依赖注入服务使用参数化构造函数创建 XAML 元素?或者还有其他方法来传递依赖关系吗?我想要有一些depe的行为...

回答 2 投票 0

如何使用.NET MAUI中的代码访问全局资源字典中定义的样式?

我在 Styles.xaml 文件中定义了样式,例如: <Setter Property="Margin" Value=&q...</desc> <question vote="0"> <p>我在 Styles.xaml 文件中定义了样式,例如:</p> <pre><code>&lt;Style x:Key=&#34;LabelFiledVerticalStyle&#34; TargetType=&#34;Label&#34;&gt; &lt;Setter Property=&#34;Margin&#34; Value=&#34;0,7,0,0&#34; /&gt; &lt;/Style&gt; </code></pre> <h3>方式1</h3> <p>我想从我的代码隐藏文件中访问它,所以我这样做了:</p> <pre><code>var LabelStyle = (Style)Application.Current.Resources[&#34;LabelFiledVerticalStyle&#34;]; </code></pre> <p>当我运行该应用程序时,出现以下错误: 字典中不存在资源“LabelFiledVerticalStyle”</p> <h3>方式2通过代码通过key访问资源</h3> <p>我查阅了微软提供的官方文档,找到了其他方法。所以,也尝试过:</p> <pre><code>var hasValue = Resources.TryGetValue(&#34;LabelFiledVerticalStyle&#34;, out object style); if (hasValue) { var LabelStyle = (Style)style; } </code></pre> <p>在这方面我也得到了 hasValue = false,尽管样式存在于资源字典中。</p> <p>有人知道我们如何从代码隐藏中访问它吗?请告诉我。</p> </question> <answer tick="false" vote="0"> <p><strong>第一种方式</strong></p> <p>如果你想用第一种方式访问样式,我们通常在文件中定义样式<pre><code>App.xaml</code></pre></p> <p>例如,我们可以在<pre><code>App.xaml</code></pre>中定义样式,如下:</p> <pre><code> &lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt; &lt;Application xmlns=&#34;http://xamarin.com/schemas/2014/forms&#34; xmlns:x=&#34;http://schemas.microsoft.com/winfx/2009/xaml&#34; x:Class=&#34;Styles.App&#34;&gt;       &lt;Application.Resources&gt;             &lt;ResourceDictionary&gt;                   &lt;Style x:Key=&#34;buttonStyle&#34; TargetType=&#34;Button&#34;&gt;                         &lt;Setter Property=&#34;HorizontalOptions&#34; Value=&#34;Center&#34; /&gt;                         &lt;Setter Property=&#34;VerticalOptions&#34; Value=&#34;CenterAndExpand&#34; /&gt;                         &lt;Setter Property=&#34;BorderColor&#34; Value=&#34;Lime&#34; /&gt;                         &lt;Setter Property=&#34;CornerRadius&#34; Value=&#34;5&#34; /&gt;                         &lt;Setter Property=&#34;BorderWidth&#34; Value=&#34;5&#34; /&gt;                         &lt;Setter Property=&#34;WidthRequest&#34; Value=&#34;200&#34; /&gt;                         &lt;Setter Property=&#34;TextColor&#34; Value=&#34;Teal&#34; /&gt;                   &lt;/Style&gt; &lt;!-- ContentPage --&gt; &lt;Style TargetType=&#34;ContentPage&#34; ApplyToDerivedTypes=&#34;True&#34;&gt; &lt;Setter Property=&#34;BackgroundColor&#34; Value=&#34;WhiteSmoke&#34; /&gt; &lt;/Style&gt; &lt;!--define the style of Label here--&gt; &lt;Style x:Key=&#34;LabelFiledVerticalStyle&#34; TargetType=&#34;Label&#34;&gt; &lt;Setter Property=&#34;Margin&#34; Value=&#34;0,7,0,0&#34; /&gt; &lt;Setter Property=&#34;TextColor&#34; Value=&#34;Red&#34; /&gt; &lt;/Style&gt; &lt;/ResourceDictionary&gt;       &lt;/Application.Resources&gt; &lt;/Application&gt; </code></pre> <p>然后在我们的页面中,我们可以通过代码访问样式:</p> <pre><code>new Label { Text=&#34;test label&#34;,Style=(Style)Application.Current.Resources [&#34;LabelFiledVerticalStyle&#34;]} </code></pre> <p>使用示例:</p> <pre><code>public class ApplicationStylesPageCS : ContentPage       {             public ApplicationStylesPageCS ()             {                   Title = &#34;Application&#34;;                   IconImageSource = &#34;csharp.png&#34;;                   Padding = new Thickness (0, 20, 0, 0);                   Content = new StackLayout {                         Children = {                               new Button { Text = &#34;These buttons&#34;, Style = (Style)Application.Current.Resources [&#34;buttonStyle&#34;] },                               new Label { Text=&#34;test label&#34;,Style=(Style)Application.Current.Resources [&#34;LabelFiledVerticalStyle&#34;]}                         }                   };             }       } </code></pre> <p>有关更多信息,您可以查看文档<a href="https://learn.microsoft.com/en-us/xamarin/xamarin-forms/user-interface/styles/xaml/application" rel="nofollow noreferrer">Xamarin.Forms中的全局样式</a>。</p> <p><strong>第二种方式</strong></p> <p>如果您创建一个<pre><code>ResourceDictionary</code></pre>(例如<pre><code>MyResourceDictionary.xaml</code></pre>)并将您的样式添加到<pre><code>ResourceDictionary</code></pre>,如下所示:</p> <p><pre><code>MyResourceDictionary.xaml</code></pre></p> <pre><code>&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt; &lt;ResourceDictionary xmlns=&#34;http://xamarin.com/schemas/2014/forms&#34; xmlns:x=&#34;http://schemas.microsoft.com/winfx/2009/xaml&#34;&gt; &lt;!--define the style of Label here--&gt; &lt;Style x:Key=&#34;LabelFiledVerticalStyle&#34; TargetType=&#34;Label&#34;&gt; &lt;Setter Property=&#34;Margin&#34; Value=&#34;0,7,0,0&#34; /&gt; &lt;Setter Property=&#34;TextColor&#34; Value=&#34;Red&#34; /&gt; &lt;/Style&gt; &lt;/ResourceDictionary&gt; </code></pre> <p>然后,如果我们想访问样式,我们应该将上面的 <pre><code>ResourceDictionary </code></pre> 添加到页面的 <pre><code>ContentPage.Resources</code></pre> 中。 </p> <pre><code>&lt;ContentPage.Resources&gt; &lt;!--add your ResourceDictionary here--&gt; &lt;ResourceDictionary Source=&#34;MyResourceDictionary.xaml&#34; /&gt; &lt;/ContentPage.Resources&gt; </code></pre> <p>您可以参考这里的示例代码:</p> <p><pre><code>ApplicationStylesPage.xaml</code></pre></p> <pre><code> &lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34;?&gt; &lt;ContentPage xmlns=&#34;http://xamarin.com/schemas/2014/forms&#34; xmlns:x=&#34;http://schemas.microsoft.com/winfx/2009/xaml&#34; x:Class=&#34;Styles.ApplicationStylesPage&#34; Title=&#34;Application&#34; IconImageSource=&#34;xaml.png&#34;&gt;       &lt;ContentPage.Resources&gt; &lt;!--add your ResourceDictionary here--&gt; &lt;ResourceDictionary Source=&#34;MyResourceDictionary.xaml&#34; /&gt; &lt;ResourceDictionary&gt;                   &lt;Style x:Key=&#34;buttonStyle&#34; TargetType=&#34;Button&#34;&gt;                         &lt;Setter Property=&#34;HorizontalOptions&#34; Value=&#34;Center&#34; /&gt;                         &lt;Setter Property=&#34;VerticalOptions&#34; Value=&#34;CenterAndExpand&#34; /&gt;                         &lt;Setter Property=&#34;BorderColor&#34; Value=&#34;Lime&#34; /&gt;                         &lt;Setter Property=&#34;CornerRadius&#34; Value=&#34;5&#34; /&gt;                         &lt;Setter Property=&#34;BorderWidth&#34; Value=&#34;5&#34; /&gt;                         &lt;Setter Property=&#34;WidthRequest&#34; Value=&#34;200&#34; /&gt;                         &lt;Setter Property=&#34;TextColor&#34; Value=&#34;Red&#34; /&gt;                   &lt;/Style&gt;             &lt;/ResourceDictionary&gt;       &lt;/ContentPage.Resources&gt;       &lt;ContentPage.Content&gt;             &lt;StackLayout Padding=&#34;0,20,0,0&#34;&gt;                   &lt;Button Text=&#34;application style overrides&#34; Style=&#34;{StaticResource buttonStyle}&#34; Clicked=&#34;Button_Clicked&#34; /&gt;             &lt;/StackLayout&gt;       &lt;/ContentPage.Content&gt; &lt;/ContentPage&gt; </code></pre> <p><pre><code>ApplicationStylesPage.xaml.cs</code></pre></p> <p>      </p> <pre><code>public partial class ApplicationStylesPage : ContentPage       {             public ApplicationStylesPage ()             {                   InitializeComponent ();             } private void Button_Clicked(object sender, System.EventArgs e) { var hasValue = Resources.TryGetValue(&#34;LabelFiledVerticalStyle&#34;, out object style); if (hasValue) { var LabelStyle = (Style)style; } } } </code></pre> </answer> <answer tick="false" vote="0"> <p>我遇到了类似的问题,解决方案非常有帮助,但有一个警告:</p> <p>在常规的 Maui 应用程序中,资源不会位于 Resources 中,而是位于 App.Current.Resources 中,如果一开始上述解决方案不起作用,请使用此解决方案。</p> </answer> </body></html>

回答 0 投票 0

Xamarin - PopAsync() 之后刷新列表

我正在使用 Xamarin 表单编写应用程序。当我使用 popAsync() 离开编辑列表的页面时,我想刷新上一页上的列表,以便显示我的更改......

回答 4 投票 0

如何向 .NET Maui 应用程序中的所有按钮添加全局单击事件处理程序?

我有一个 .NET Maui 应用程序,应该将用户事件写入日志文件。我一直在做的是将这段代码放在每个基页或不继承该基页的页面中。 我学会了...

回答 1 投票 0

xamarin.forms (android) 无法更新应用程序商店中的应用程序“android:exported”属性缺失

截至今天,某些事情一定发生了变化,因为我们无法在应用程序商店中更新我们的应用程序。 我们在上传时收到此错误: 警告:如果活动、服务或广播接收器使用 Intent fi...

回答 2 投票 0

活动指示器不会更改可见属性并显示整个页面

我正在开发一个xamarin表单应用程序,我想添加以显示“正在加载”状态。但我现在就面临这个问题。当我打开该页面时,会显示底部堆栈布局,但它永远不会改变...

回答 1 投票 0

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