小编Cfu*_*fun的帖子

在 Xamarin Forms shell 中打开左侧菜单时发生的事件

我正在使用 xamarin forms shell。我有 1 个图像和 1 个标签来分配用户的姓名和个人资料图片。我希望每次打开菜单(按下按钮或向右拖动)时再次更新该值,但我找不到与之相关的任何事件。有人请帮帮我吧

c# xamarin xamarin.forms xamarin.forms.shell

3
推荐指数
1
解决办法
1477
查看次数

Xamarin Form Shell:Flyout 与 TabBar

读了这句话我很困惑

TabBar 禁用 Flyout

在 Xamarin 文档中。但即使是示例代码也以 Flyout 布局显示 TabBar。我想,我误解了 Flyout 和 TabBar (我的想法如附件所示)。任何人都可以想象其中的差异。Google 搜索并没有给出太多关于 TabBar 的信息,它只是显示了标准文档。

在此输入图像描述

xaml tabs flyout xamarin.forms xamarin.forms.shell

3
推荐指数
1
解决办法
2125
查看次数

在 Xamarin Forms 5.0.0 中未找到 Expander

我有一个Expander在我的应用程序中一直有效的方法。我将 Xamarin Forms 更新到版本 5.0.0,XAML 向我发出错误信号,控件不再存在。

未找到“扩展器”类型。验证您没有缺少程序集引用并且所有引用的程序集均已构建。

它改名了吗?被删除了吗?

xaml xamarin.forms xamarin-community-toolkit

3
推荐指数
1
解决办法
4145
查看次数

xaml 设计器或预览器未显示

Xamarin.Forms 设计视图不显示 .xaml 的预览我该怎么办?我寻找答案,我做了所有社区建议,但没有任何效果。我开始认为 Xamarin.Forms 没有 .xaml 的预览,对吗?或者那些按钮在哪里?我怎么能得到它们?

在此处输入图片说明

这是我的观点: 在此处输入图片说明

visual-studio xamarin xamarin.forms xamarin-previewer

3
推荐指数
1
解决办法
1566
查看次数

Program.cs 中的 MAUI 依赖注入服务解析

MAUI 的依赖注入设置类似于 ASP.NET Core 在 Startup.cs 类中的设置。默认情况下,此设置在MauiProgram.cs文件中。

我的问题是:服务注册后如何获取此文件中的服务实例?我想,一种解决方案如下,但是如果这些服务的构造函数在一段时间内发生变化,我也必须编辑此代码:

    var keyValueStore = new PreferencesKeyValueStore();
    var accountService = new AccountService(keyValueStore);
    var profileService = new ProfileService(keyValueStore);
    
    builder.Services.AddSingleton<IKeyValueStore>(keyValueStore);
    builder.Services.AddSingleton<IAccountService>(accountService);
    builder.Services.AddSingleton<IProfileService>(profileService);

    //Here now I can use accountService and profileService to do something
Run Code Online (Sandbox Code Playgroud)

我找不到更优雅的解决方案来从 DI 容器返回服务实例。就像是:

    builder.Services.AddSingleton<IKeyValueStore, PreferencesKeyValueStore>();
    builder.Services.AddSingleton<IAccountService, AccountService>;
    builder.Services.AddSingleton<IProfileService, ProfileService>();
    
    //Now I can't perform something like: var accountService = diContainer.GetInstance<IAccountService>(); or similar.
Run Code Online (Sandbox Code Playgroud)

我不知道如何访问 di 容器并要求它向我提供注册实例。

c# dependency-injection asp.net-core maui

3
推荐指数
1
解决办法
2262
查看次数

如何在 MVVM 架构中使用 LottieForms 绑定动画视图播放?

所以我在列表视图中使用动画,我想随时播放一次,所以我想控制它。

这是图书馆https://github.com/martijn00/LottieXamarin

我有一堂课:

public class Info {
   public bool ReadMoreIconVisibility {get;set;}
}    
Run Code Online (Sandbox Code Playgroud)

和xaml:

<forms:AnimationView Animation = "animationone.json" Loop = "false" IsVisible="{Binding ReadMoreIconVisibiliy}"/>
Run Code Online (Sandbox Code Playgroud)

我可以成功地使用我的 xaml 来隐藏/不隐藏我的动画。但是我如何达到AnimationView.Play()方法,只有在我命名我的标签时才可用x:name

我如何利用 mvvm 架构师来Play制作我的动画?

我无法使用命令参数,因为它已被同一列表视图中的另一个项目使用:

 <Button Command="{Binding Click}" CommandParameter="{x:Reference otherItemInListView}"/>
Run Code Online (Sandbox Code Playgroud)

一种解决方案可能是使用另一个对象扩展命令参数,如果是这样,如何实现?不过,最好有另一种解决方案。

c# xaml xamarin xamarin.forms lottie

2
推荐指数
1
解决办法
785
查看次数

Drawable“无法解析此资源 URL”

好的,我浏览了 android 文档,搜索了示例,并阅读了类似这样的 stackoverflow 问题:无法解析符号 @drawable/ic_launcher,但我仍然无法弄清楚发生了什么。

我的 Xamarin Android 应用程序中有一个 ImageButton,我已在 XML 文件中定义了它。这里:

    <TextView
        android:layout_width="40sp"
        android:layout_height="wrap_content"
        android:text=""
        android:gravity="center" />
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="vertical">
        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/increase_quantity_button"
            android:src="@drawable/arrow_drop_up"
            android:contentDescription="@string/increaseQuantity"/>
        <ImageButton
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:id="@+id/decrease_quantity_button"
            android:src="@drawable/arrow_drop_down"
            android:contentDescription="@string/decreaseQuantity"/>
    </LinearLayout>
    <ImageButton
        android:layout_width="40sp"
        android:layout_height="wrap_content"
        android:id="@+id/delete_item_button"
        android:src="@drawable/delete"
        android:contentDescription="@string/delete"/>

</LinearLayout>
<TextView
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/item_description"/>
Run Code Online (Sandbox Code Playgroud)

然后我将这些文件放入我的可绘制文件夹中,如下所示。

在此输入图像描述

然后,当我构建应用程序时,我得到:This resource URL cannot be resolved

我不知道下一步该尝试什么。

c# android xamarin.android xamarin

2
推荐指数
1
解决办法
1214
查看次数

在 Shell 中动态创建 FlyoutItem 列表?

目前我使用MasterDetailPage但我想将我的项目模型更改为Shell.

如何像我的旧版本一样动态生成 FlyoutItems MasterDetail

<StackLayout>
        <ListView x:Name="MenuItemsListView"
              SeparatorVisibility="None"
              HasUnevenRows="true"
              ItemsSource="{Binding MenuItems}">
            <ListView.Header>
                <Grid BackgroundColor="#8f0000">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="10"/>
                        <ColumnDefinition Width="*"/>
                        <ColumnDefinition Width="10"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="30"/>
                        <RowDefinition Height="80"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="10"/>
                    </Grid.RowDefinitions>
                    <Label
                          Grid.Column="1"
                          Grid.Row="2"
                          Text="{Binding Title}"
                          Style="{DynamicResource SubtitleStyle}" 
                          TextColor="#d7d9b4"
                          FontSize="24"/>
                </Grid>
            </ListView.Header>
            <ListView.ItemTemplate>
                <DataTemplate>
                    <ViewCell>
                        <StackLayout Padding="15,10" HorizontalOptions="FillAndExpand">
                            <Label VerticalOptions="FillAndExpand" 
                                    VerticalTextAlignment="Center" 
                                    Text="{Binding MenuTitle}" 
                                    d:Text="{Binding .}"
                                    FontSize="20"/> 
                        </StackLayout>
                    </ViewCell>
                </DataTemplate>
            </ListView.ItemTemplate>
        </ListView>        
    </StackLayout>
Run Code Online (Sandbox Code Playgroud)

您有动态 FlyoutItems 的示例吗?

c# xaml xamarin xamarin.forms xamarin.forms.shell

2
推荐指数
1
解决办法
3087
查看次数

如何以编程方式移动和最小化 Maui Windows 应用程序

我有一个带有 blazor 的毛伊岛应用程序,我正在创建一个自定义标题栏。

我即将关闭 maui 应用程序,在 blazor 上使用Application.Current.Quit();

现在我怎样才能最小化和移动毛伊岛应用程序

我的代码 Blazor

private void MoveWindow()
{
    
}

private void MinimizeWindow()
{
        
}


private void CloseWindow() {
    Application.Current.Quit();
}
Run Code Online (Sandbox Code Playgroud)

c# winui-3 maui .net-maui

2
推荐指数
1
解决办法
1513
查看次数

Maui 可以配置直线阴影吗?

我\xc2\xb4m 在 .net maui 中开发一个应用程序,我有一个问题,但我没有通过浏览回答自己。\n我正在尝试将阴影应用到边框,并且以下代码完美运行。

\n
   <Border \n    Style="{StaticResource light-theme-border}"\n    Grid.Column="1"\n    Grid.Row="3"\n    Grid.ColumnSpan="7">\n    <Border.Shadow>\n        <Shadow \n                Brush="red"\n                Offset="1,11"\n                Radius="20"\n                Opacity="0.25"/>\n    </Border.Shadow>\n   </Border>\n
Run Code Online (Sandbox Code Playgroud)\n

但是当我直接在边框属性内写入阴影时,它会捕获该属性,但我不知道如何转储[画笔、偏移、半径和不透明度]信息:

\n
    <Border \n        Style="{StaticResource light-theme-border}"\n        Grid.Column="1"\n        Grid.Row="3"\n        Grid.ColumnSpan="7"\n        Shadow="???????????????????????????">\n    </Border>\n
Run Code Online (Sandbox Code Playgroud)\n

xaml shadow maui .net-maui

2
推荐指数
1
解决办法
2864
查看次数