小编Cfu*_*fun的帖子

如何在没有导航页面的情况下更改状态栏颜色

我想更改某些视图上的状态栏颜色。

我找到了这个解决方案https://github.com/yuv4ik/XFDynamicStatusBarAppearance

但它仅适用于 NavigationPage。

我不需要从我的应用程序导航页面...

    public App()
    {
        InitializeComponent();

        MainPage = new MainPage();
    }
Run Code Online (Sandbox Code Playgroud)

这是我的尝试...

    var statusBarStyleManager = DependencyService.Get<IStatusBarStyleManager>();

    MainCarousel.PositionChanged += (sender, e) =>
    {
        switch (e.CurrentPosition)
        {
            case 1:
                Device.BeginInvokeOnMainThread(() =>
                {
                    Xamarin.Forms.Application.Current.MainPage.SetValue(Xamarin.Forms.NavigationPage.BarBackgroundColorProperty, Color.DarkCyan);

                    //((Xamarin.Forms.NavigationPage)Xamarin.Forms.Application.Current.MainPage).BarBackgroundColor = Color.DarkCyan;
                    statusBarStyleManager.SetDarkTheme();
                });
                break;
            case 0:
            case 2:
                Device.BeginInvokeOnMainThread(() =>
                {
                    Xamarin.Forms.Application.Current.MainPage.SetValue(Xamarin.Forms.NavigationPage.BarBackgroundColorProperty, Color.LightGreen);
                    statusBarStyleManager.SetLightTheme();
                });
                break;
            default:
                break;
        }
    };
Run Code Online (Sandbox Code Playgroud)

如何更改状态栏颜色?

c# xamarin.ios xamarin.android xamarin xamarin.forms

5
推荐指数
2
解决办法
4581
查看次数

.NET Core Linux Kestrel https 配置

我们正在 Linux(Ubuntu 18.04 LTS 和 Apache2)上部署我们的第一个 .NET Core 应用程序。

我们不知道部署它们的服务器的证书,也不知道它们将部署的端口,因为它们是客户端的,我们没有访问权限,所以我们需要能够通过 appsettings 中的配置输入它们(红隼配置)。

在 Windows 中,api 在 http 和 https 中都可以正常工作,将此配置放入appsettings.json并在Startup.cs 中读取它,如下所示:

// kestrel configuration
services.Configure<KestrelServerOptions>(Configuration.GetSection("Kestrel"));
Run Code Online (Sandbox Code Playgroud)

我们的windows配置appsettings.json是:

"AllowedHosts": "*.mydomain.es;*.mydomain-eu.com;test-win;test-linux;localhost;127.0.0.1;*.myActiveDirectoryDomain.ad",
"Kestrel": {
"Endpoints": {
  "Http": {
    "Url": "http://localhost:5009"
  }
  ,"Https": {
    "Url": "https://localhost:5010"    
  }
}
}
Run Code Online (Sandbox Code Playgroud)

使用相同配置部署在 Linux 上时,Kestrel 服务不会启动。红隼服务错误:

须藤 systemctl 状态 kestrel-apieu.service ?kestrel-apieu.service - 在 Ubuntu 18.04 上运行的示例 ASP .NET Api 加载:加载(/etc/systemd/system/kestrel-apieu.service;启用;供应商预设:启用)活动:激活(自动重启)(结果: core-dump ) 自 2020-02-06 星期四 …

linux ssl https asp.net-core

5
推荐指数
1
解决办法
4522
查看次数

在 Xamarin 表单中添加长按手势识别器

您能否让我知道如何在 Xamarin Forms 应用程序中识别长按手势?

这是我创建的 xaml 页面,参考此线程:Xamarin.forms.DataGrid

<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:DataGridSample_01"
xmlns:dg="clr-namespace:Xamarin.Forms.DataGrid;assembly=Xamarin.Forms.DataGrid"
x:Class="DataGridSample_01.MainPage">

 <ContentView BackgroundColor="White" Padding="20" >
  <dg:DataGrid ItemsSource="{Binding Data}" SelectionEnabled="True" RowHeight="70" HeaderHeight="50" BorderColor="#CCCCCC" HeaderBackground="#E0E6F8" ActiveRowColor="#8899AA">
     <dg:DataGrid.Columns>
     <dg:DataGridColumn Title="Logo" PropertyName="Logo" Width="50" SortingEnabled="False">
        <dg:DataGridColumn.CellTemplate>
           <DataTemplate>
              <Image Source="{Binding}" HorizontalOptions="Center" VerticalOptions="Center" Aspect="AspectFit" HeightRequest="60" />
           </DataTemplate>
        </dg:DataGridColumn.CellTemplate>
     </dg:DataGridColumn>
     <dg:DataGridColumn Title="Team" PropertyName="Name" Width="2*" >
     </dg:DataGridColumn>
     <dg:DataGridColumn Title="Win" PropertyName="Win" Width="2*">
        <dg:DataGridColumn.CellTemplate>
           <DataTemplate>
              <Picker x:Name="Fruits" Title="Fruits" HorizontalOptions="FillAndExpand">
                 <Picker.Items>
                    <x:String>Apple</x:String>
                    <x:String>Mango</x:String>
                    <x:String>PineApple</x:String>
                    <x:String>Orange</x:String>
                 </Picker.Items>
              </Picker>
           </DataTemplate>
        </dg:DataGridColumn.CellTemplate>
     </dg:DataGridColumn>
     <dg:DataGridColumn Title="Loose" PropertyName="Loose"  Width="1*">                    
     </dg:DataGridColumn>
     <dg:DataGridColumn PropertyName="Home">
        <dg:DataGridColumn.FormattedTitle>
           <FormattedString> …
Run Code Online (Sandbox Code Playgroud)

c# xaml xamarin.android long-press xamarin.forms

4
推荐指数
2
解决办法
6058
查看次数

INotifyPropertyChanged And derived properties on different objects

Recently I inherited a pretty big project developed in C# and WPF. It uses bindings along with the INotifyPropertyChanged interface to propagate changes to/from the View.

A little preface: In different classes I have properties that depend on other properties in the same class (think for example the property TaxCode that depends on properties like Name and Lastname). With the help of some code I found here on SO (can't find again the answer though) I created the abstract …

c# data-binding wpf parent-child inotifypropertychanged

4
推荐指数
1
解决办法
3468
查看次数

检测 Shell 弹出窗口是否打开

有什么办法可以处理打开 Flyout 的情况吗?我正在尝试在打开期间或打开弹出窗口后添加自定义行为。

我找不到任何类型的财产,例如 Shell.OnFlyoutOpening="flyout_opening"

c# xamarin xamarin.forms xamarin.forms.shell

4
推荐指数
1
解决办法
591
查看次数

Xamarin.Forms 中正确的 Page.Loaded 事件

在过去的两个月里,我一直在不知疲倦地寻找一种Page.Loaded在使用 Xamarin.Forms 时实现正确事件的方法,但我无法实现或找到一种方法来实现它。

大多数人建议重写Page.OnAppearing或添加事件处理程序,Page.Appearing这两者都不是答案或实现所需效果的正确方法,并且事件的行为不像真实Page.Loaded事件那样。

我想了解以下信息:

  • 为什么 Xamarin.Forms 没有内置Page.Loaded事件?
  • 有解决办法吗?
  • 我可以从本机端实现它吗?

编辑:

我所说的“适当的Page.Loaded”事件是指:

  • 它必须被调用一次,且仅当页面加载了所有控件、布置它们、初始化它们并首次呈现它们时。

  • 从模态页面返回时不得调用它。

lifecycle xamarin.forms

4
推荐指数
1
解决办法
9586
查看次数

样式取决于 Xamarin 表单中的屏幕方向

我在手机和平​​板电脑上进行造型,但如何添加方向选项?这都是纵向的,但我如何添加水平方向的选项?

 <Style TargetType="Grid" x:Key="DocType">
                        <Setter Property="HeightRequest">
                        <Setter.Value>
                            <OnIdiom Phone="50" Tablet="80" />
                        </Setter.Value>
                    </Setter>
                 <Setter Property="BackgroundColor" Value="#F4F5F7"/>
             </Style>
Run Code Online (Sandbox Code Playgroud)

xaml styling adaptive-design xamarin.forms

4
推荐指数
1
解决办法
1245
查看次数

无法解析类型“Expander”

我的 Expander 不再接受 AncestorType 属性中的 Binding 中的 Expander 值。它曾经可以工作,但自从我升级到 Xamarin forms 版本 5.0.0 后,它就不再工作了,Visual Studio 向我报告以下错误:

错误 XFC0000 无法解析类型“Expander”。

<xct:Expander.Header>
        <Image Source="ExpanderPlus.png" WidthRequest="30" HeightRequest="30" Rotation="180">
             <Image.Triggers>
                    <DataTrigger TargetType="Image"
                                 Binding="{Binding Source={RelativeSource AncestorType={x:Type Expander}}, Path=IsExpanded}"
                                 Value="True">
                            <Setter Property="Source" Value="ExpanderClose.png"/>
                    </DataTrigger>
             </Image.Triggers>
        </Image>
</xct:Expander.Header>
Run Code Online (Sandbox Code Playgroud)

xaml expander xamarin.forms xamarin-community-toolkit

4
推荐指数
1
解决办法
3726
查看次数

.NET MAUI 全尺寸背景图像(覆盖元素)

由于 .NET MAUI 是 Xamarin 的继承者,我正在尝试将 Xamarin 布局移植到新的 Maui 版本。已从RelativeLayout毛伊岛移除。我使用 来RelativeLayout将 GUI 放置在图像之上。该图像是全屏背景图像,长度拉伸,保持其比例。

我可以创建相同的布局,但背景中有一个全屏图像,高度为 100% 并保持其比例。我将如何在 .NET Maui 中执行此操作?它并不是真正关于如何使图像拉伸,而是将布局元素(如条目、标签等)放在图像之上。

xaml overlay background maui

4
推荐指数
1
解决办法
1万
查看次数

插入“Label.Text”的 VisualState.Setters 属性时页面崩溃

我有一个带有标签和开关的 .NET MAUI xaml 页面。当我尝试使用VisualState-setters 更改打开/关闭时的标签文本值时,它可以与模拟器和手机调试器模式一起使用,但是当我将其下载到我的 Android 手机中时,尝试打开时页面崩溃!这是重现问题的代码部分:

    <HorizontalStackLayout Grid.Row="2" Grid.Column="0" Margin="5" Spacing="7" BackgroundColor="White" HeightRequest="50">
                                
                <!-- Automatic-Manual -->
                <VerticalStackLayout Margin="2" >
                    <Label x:Name="LblAutoMan" Text="Automatic" VerticalOptions="Start" HorizontalOptions="Center" HeightRequest="20" WidthRequest="65"/>
                    <Switch IsToggled="True" HorizontalOptions="Start" VerticalOptions="Center" HeightRequest="10">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup Name="CommonStates">
                                <VisualState Name="On">
                                    <VisualState.Setters>
                                        <Setter Property="ThumbColor" Value="Green" />
                                        <Setter TargetName="LblAutoMan" Property="Label.Text" Value="Automatic" /> 
                                    </VisualState.Setters>
                                </VisualState>
                                <VisualState Name="Off">
                                    <VisualState.Setters>
                                        <Setter Property="ThumbColor" Value="Red" />
                                        <Setter TargetName="LblAutoMan" Property="Label.Text" Value="Manual" /> 
                                    </VisualState.Setters>
                                </VisualState>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                    </Switch>
                </VerticalStackLayout>
               
            </HorizontalStackLayout>
Run Code Online (Sandbox Code Playgroud)

如果我评论两行:<Setter TargetName="LblAutoMan"

有人可以解决这个错误吗?

xaml visualstatemanager .net-maui

4
推荐指数
1
解决办法
527
查看次数