我正在尝试为 Blazor 上的 editform 创建一个从输入库派生的定制输入,但是我很难掌握它,因为我这周才刚刚学习 Blazor,一般来说,这个月才学习 C#。
我找到了 https://www.meziantou.net/creating-a-inputselect-component-for-enumerations-in-blazor.htm(或找到下面粘贴的代码)并能够将其用于 inputselect 内部的可为空枚举然而,尝试为可空的输入复选框复制它却没有成功。我想知道是否有人有链接或知道如何调整它以使其发挥作用。
预先感谢您,我几乎整天都在电脑上,所以请随意提问,尽量不要责备我哈哈。
// file: Shared/InputSelectEnum.cs
using System;
using System.ComponentModel.DataAnnotations;
using System.Globalization;
using System.Reflection;
using Humanizer;
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.Components.Forms;
using Microsoft.AspNetCore.Components.Rendering;
// Inherit from InputBase so the hard work is already implemented
// Note that adding a constraint on TEnum (where T : Enum) doesn't work when used in the view, Razor raises an error at build time. Also, this would prevent using nullable types...
namespace OrderServiceFrontEnd.Shared
{
public …Run Code Online (Sandbox Code Playgroud) Xamarin.Forms 我的问题至少存在于 Android 上。
我有一个使用分组的集合视图。我想让每个 CollectionView 组都可单击。我尝试将 tapGesture 识别器添加到第二个数据模板中的 StackLayout、顶部数据模板中的 Label 和 CollectionView 本身,我还尝试将它们作为点击和命令添加。最后,我在 collectionView 上尝试了 SelectionChanged 。
单击 CollectionView 上的任意位置不会命中 ViewModel 或 View.cs 中的断点
我希望单击一个项目将为 ViewModel 提供某种参数,以便它知道 CollectionView 中的哪个项目被点击
这是我的 XAML,如果有人能看到我犯了什么错误,那就太棒了!谢谢
<CollectionView Grid.Row="1" ItemsSource="{Binding ResponseCollection}" SelectionMode="Single" SelectionChanged="ResponseCollectionView_SelectionChanged" x:Name="ResponseCollectionView" IsGrouped="True" >
<CollectionView.GroupHeaderTemplate>
<DataTemplate >
<Label BackgroundColor="White" Padding="10,10,10,0" Text="{Binding Response}">
</Label>
</DataTemplate>
</CollectionView.GroupHeaderTemplate>
<CollectionView.ItemTemplate>
<DataTemplate>
<ScrollView>
<Grid Padding="10" BackgroundColor="White">
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="1"/>
</Grid.RowDefinitions>
<StackLayout Grid.Row="0" Orientation="Horizontal">
<Label TextColor="Red" Text="{Binding Statistic}"/>
<Label TextColor="Red" Text="{Binding Amount}"/>
</StackLayout>
<BoxView Grid.Row="1" BackgroundColor="Gray" HorizontalOptions="FillAndExpand"></BoxView> …Run Code Online (Sandbox Code Playgroud)