custom-controls 相关问题

自定义控件是可重用的GUI元素,从现有控件类型派生,使用其他行为,功能和/或外观进行自定义。

ASCX 用户控件未显示

我正在向现有网络应用程序添加报告部分。该部分由通过两个不同的 .ascx 文件加载的两个页面组成。我不允许修改任何关于 h 的内部逻辑...

回答 1 投票 0

可以覆盖fabricjs中的边界框选择区域 - 控件选项

在这里,我们正在fabric.js中使用创建设计工具。我们在fabric.js中为画布对象创建了自定义选择区域。我阅读了fabric.js中的源代码,它生成了用于边界的方框...

回答 2 投票 0

内容视图业务逻辑操作去哪里

我正在开发 .net maui 应用程序,我需要在自定义控件中获取和设置数据。 目标是: 操作模板 这一页: 我正在开发 .net maui 应用程序,我需要在自定义控件中获取和设置数据。 目标是: 页面: <ContentPage x:Class="V7.UIS.MauiMobile.Views.AboutPage" xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:controls="clr-namespace:V7.UIS.MauiMobile.Controls.Views" xmlns:viewmodel="clr-namespace:V7.UIS.MauiMobile.ViewModels" Title="About" ios:Page.UseSafeArea="true" x:DataType="viewmodel:AboutViewModel" BackgroundColor="{StaticResource NormalBackgroundColor}"> <VerticalStackLayout> <controls:ItemBarcodeSearchView /> <Entry Text="Count" /> <Button Grid.Row="1" Grid.Column="1" Command="{Binding AddCommand}" Text="Add" /> </VerticalStackLayout> </ContentPage> 自定义控件xaml: <?xml version="1.0" encoding="utf-8" ?> <ContentView x:Class="V7.UIS.MauiMobile.Controls.Views.ItemBarcodeSearchView" xmlns="http://schemas.microsoft.com/dotnet/2021/maui" xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" xmlns:dxe="clr-namespace:DevExpress.Maui.Editors;assembly=DevExpress.Maui.Editors" x:Name="BarcodeSearchView"> <ContentView.ControlTemplate> <ControlTemplate> <VerticalStackLayout> <Grid x:Name="ButtonGrid" Margin="5" IsVisible="{TemplateBinding IsVisibleButtonGrid}"> <Button Clicked="ShowView" Text="Enter Barcode" /> </Grid> <Grid x:Name="DetailGrid" Padding="15" ColumnDefinitions="*" ColumnSpacing="20" IsVisible="{TemplateBinding IsVisibleDetailGrid}" RowDefinitions="Auto,Auto" VerticalOptions="Center"> <dxe:TextEdit Grid.Row="0" Margin="0" ClearIconCommand="{TemplateBinding ClearFieldsCommand}" ClearIconVisibility="Always" LabelText="Barcode" Text="{TemplateBinding Barcode}" /> <dxe:TextEdit Grid.Row="1" Margin="0" ClearIconVisibility="Never" LabelText="Item" Text="{TemplateBinding ItemDescription}" /> <Button Grid.Row="6" Margin="0,10,0,0" Command="{Binding Source={x:Reference BarcodeSearchView}, Path=Search}" Text="Search" /> <Button Grid.Row="7" Margin="0,10,0,0" Clicked="SendBarcodeDetails" Text="Ok" /> </Grid> </VerticalStackLayout> </ControlTemplate> </ContentView.ControlTemplate> </ContentView> 当我按下搜索按钮时,我想执行此命令来设置项目描述。这是该内容视图的业务逻辑,我不想一遍又一遍地重复此代码。: private readonly HttpClient _client; public blabla(IHttpClientFactory factory) { _client = factory?.CreateClient(AppConstants.ApiName); } GetBarcodeDetailQuery query = new() { Barcode = barcode }; await client.GetDataFromApi<GetBarcodeDetailQuery, GetBarcodeDetailViewModel>("Cards/ItemBarcode/GetBarcodeDetail", query, FindBarcodeCallBack); 我应该在哪里进行此操作以及如何进行?我一周都想不出来。 自定义控件xaml.cs: using CommunityToolkit.Mvvm.Input; using V7.UIS.MauiMobile.Models; namespace V7.UIS.MauiMobile.Controls.Views; public partial class ItemBarcodeSearchView : ContentView { public ItemBarcodeSearchView() { InitializeComponent(); IsVisibleButtonGrid = "true"; IsVisibleDetailGrid = "false"; } public event EventHandler<ItemBarcodeDetail> BarcodeDetailsReady; public static readonly BindableProperty BarcodeProperty = BindableProperty.Create(nameof(Barcode), typeof(string), typeof(ItemBarcodeSearchView)); public static readonly BindableProperty ItemDescriptionProperty = BindableProperty.Create(nameof(ItemDescription), typeof(string), typeof(ItemBarcodeSearchView)); public static readonly BindableProperty IsVisibleButtonGridProperty = BindableProperty.Create(nameof(IsVisibleButtonGrid), typeof(string), typeof(ItemBarcodeSearchView)); public static readonly BindableProperty IsVisibleDetailGridProperty = BindableProperty.Create(nameof(IsVisibleDetailGrid), typeof(string), typeof(ItemBarcodeSearchView)); public static readonly BindableProperty SearchProperty = BindableProperty.Create(nameof(Search), typeof(RelayCommand), typeof(ItemBarcodeSearchView)); public RelayCommand Search { get => (RelayCommand)GetValue(SearchProperty); set => SetValue(SearchProperty, value); } public string IsVisibleButtonGrid { get => (string)GetValue(IsVisibleButtonGridProperty); set => SetValue(IsVisibleButtonGridProperty, value); } public string IsVisibleDetailGrid { get => (string)GetValue(IsVisibleDetailGridProperty); set => SetValue(IsVisibleDetailGridProperty, value); } public string Barcode { get => (string)GetValue(BarcodeProperty); set => SetValue(BarcodeProperty, value); } public string ItemDescription { get => (string)GetValue(ItemDescriptionProperty); set => SetValue(ItemDescriptionProperty, value); } [RelayCommand] public void ClearFields() { Barcode = string.Empty; ItemDescription = string.Empty; } private void SendBarcodeDetails(object sender, EventArgs e) { ItemBarcodeDetail itemBarcodeDetail = new() { Barcode = Barcode, ItemDescription = ItemDescription }; BarcodeDetailsReady?.Invoke(sender, itemBarcodeDetail); IsVisibleButtonGrid = "true"; IsVisibleDetailGrid = "false"; } private void ShowView(object sender, EventArgs e) { IsVisibleButtonGrid = "false"; IsVisibleDetailGrid = "true"; } } 希望有人能帮助我。 ContentView类定义了一个View类型的Content属性,它表示ContentView的内容。该属性由 BindableProperty 对象支持,这意味着它可以是数据绑定和样式的目标。 ContentView 类本身提供的功能很少,但可用于创建自定义控件。创建自定义控件的过程是: 创建一个派生自 ContentView 类的类。 在代码隐藏文件中定义任何控件属性或事件 自定义控件。 定义自定义控件的 UI。 更多信息可以查看官方文档:创建自定义控件。 注: 您还可以在此处查看示例 ContentView 演示,这将帮助您了解如何使用 ContentView 创建自定义控件。虽然此示例是 Xamarin 表单的应用程序,但它也适用于 MAUI。

回答 1 投票 0

Content View 未定义公共无参数构造函数

我正在开发 .net maui 应用程序,我需要在自定义控件中使用 httpclientfactory。 我正在开发 .net maui 应用程序,我需要在自定义控件中使用 httpclientfactory。 <VerticalStackLayout> <controls:ItemBarcodeControl x:Name="control1" BarcodeDetailsReady="ItemBarcodeControl_BarcodeDetailsReady" /> <Entry Text="Depo" /> <Button Grid.Row="1" Grid.Column="1" Text="Add" Clicked="Button_Clicked"/> </VerticalStackLayout> 当我尝试在页面中使用自定义控件时,出现错误,提示 xxx 不能用作对象元素,因为它不是公共的,或者没有定义公共无参数构造函数或类型转换器。 这是我的xaml.cs public partial class ItemBarcodeControl : ContentView { private readonly HttpClient _client; public event EventHandler<ItemBarcodeDetail> BarcodeDetailsReady; //Bindable properties public ItemBarcodeControl(IHttpClientFactory factory) { InitializeComponent(); IsVisibleButtonGrid = "true"; IsVisibleDetailGrid = "false"; _client = factory?.CreateClient(AppConstants.ApiName); } public string IsVisibleButtonGrid { get => (string)GetValue(IsVisibleButtonGridProperty); set => SetValue(IsVisibleButtonGridProperty, value); } public string IsVisibleDetailGrid { get => (string)GetValue(IsVisibleDetailGridProperty); set => SetValue(IsVisibleDetailGridProperty, value); } // Property Definitions //Some Commands async Task FindItemDetails() { if (!string.IsNullOrEmpty(Barcode)) { GetBarcodeDetailQuery query = new() { Barcode = Barcode }; await _client.GetDataFromApi<GetBarcodeDetailQuery, GetBarcodeDetailViewModel>("Cards/ItemBarcode/GetBarcodeDetail", query, FindBarcodeCallBack); } } void FindBarcodeCallBack(GetBarcodeDetailViewModel vm) { ItemDescription = vm.Item.Description; ItemUnit = vm.ItemUnits.FirstOrDefault().ToString(); ItemLot = vm.Lot.ToString(); ItemSerialNumber = vm.SerialNumber.ToString(); Quantity = "0"; } // Here is my main purpose for this view. Where should i make this operation im not sure. } 希望有人能帮助我。 ContentView类定义了一个View类型的Content属性,它表示ContentView的内容。该属性由 BindableProperty 对象支持,这意味着它可以是数据绑定和样式的目标。 ContentView 类本身提供的功能很少,但可用于创建自定义控件。创建自定义控件的过程是: 创建一个派生自 ContentView 类的类。 在代码隐藏文件中定义任何控件属性或事件 自定义控件。 定义自定义控件的 UI。 更多信息可以查看官方文档:创建自定义控件。 注: 您还可以在此处查看示例 ContentView 演示,这将帮助您了解如何使用 ContentView 创建自定义控件。虽然此示例是 Xamarin 表单的应用程序,但它也适用于 MAUI。

回答 1 投票 0

如何为我的网络应用程序创建自定义“赞”按钮?

Flipboard(ios/Android)有一个 Facebook“喜欢”按钮,我试图模仿但不知道从哪里开始? 我正在考虑使用 CSS 将图像放置在通用“喜欢”按钮的顶部。任何...

回答 1 投票 0

带按钮的 WPF 自定义控件

我已经为我的应用程序创建了一个 WPF 自定义控件。我现在正在努力连接控件中某些控件的事件(ToggleButtons)。 我定义了以下内容: 窗头...

回答 1 投票 0

从 ASP.NET 自定义 Web 控件检索输入值

我正在构建一个 Web 控件,用于模糊 SSN 等输入值。 我已经编写了控件,但是,我无法在回发时检索输入值。 [默认属性(“文本”)] [工具箱数据(&

回答 2 投票 0

WPF 自定义控件绑定 - 如何确保呈现您的值

我仅用代码创建了一个自定义控件,我希望它的占用空间尽可能小,因为它将根据样式模板内网格中的值进行重复。目前它工作一些...

回答 0 投票 0

C# WinUI3修改AutosuggestBox

我正在尝试以某种方式修改标准 AutoSuggestBox,使列表视图弹出窗口比文本框本身更大: 不幸的是我被困住了。我尝试创建自己的样式定义: (标准v...

回答 0 投票 0

无法使用渲染器在 Xamarin.Forms 编辑器控件或自定义无边框编辑器中选择文本

我已经在我的 Xamarin.Forms 应用程序中使用自定义 EditorRenderer 实现了 BorderlessEditor,但我面临的问题是,在这两种情况下,编辑器文本根本无法选择,在 F 中也一样...

回答 0 投票 0

Designer 弄乱了启用设计的 Custom UserControl 子容器的位置和大小

当我将此控件放在窗体上时,更改其大小和位置,保存并关闭窗体。打开后位置和大小不一样,但是在.Designer.cs里面就是这样设置的....

回答 1 投票 0

WPF 中带三角形的二维场

我想创建我自己的派生自 ListBoxItem 的控件,在我的控件中应该存在一个将被显示的多边形。多边形应该包含 3 个点,所以是一个三角形。这个三角形应该...

回答 0 投票 0

自定义属性图片框控件

第一次尝试创建控件。 我有一个类,它继承了 PictureBox 这里有一些自定义属性 '特性

回答 2 投票 0

如何将自定义 Angular Material 控件包装到自己的组件中?

我正在尝试创建一个基于 MatFormField 的自定义控件。首先,我浏览了有关如何创建自己的自定义控件的部分中的 Angular Material 文档。 来自

回答 0 投票 0

为什么自定义绘制继承的 C# .NET TrackBar 控件不起作用?

总的来说,我是 C# 和 Visual Studio 的新手。我想要做的是创建一个自定义的 TrackBar 控件,该控件能够保存制表位并在这些位置绘制标记。我叫它

回答 0 投票 0

强制重绘 ComboBox 的 DropDownList

我正在使用绑定到 CheckBox 控件列表的 ComboBox 来制作一个选中的组合框列表。具体的实现是我自己的,但是这个想法来自一个SO问题,其链接似乎...

回答 1 投票 0

基于Canvas的WPF自定义控件,启动代码可以放在哪里?

我刚刚在VS中创建了一个新项目--自定义控件。这个控件是基于Canvas的,因为我需要一些绘图。代码大部分是自动生成的,所以我不会在这里提供所有的项目。我的目标是...

回答 1 投票 0

WPF:如何对滑块控件的各个RepeatButton进行样式设计?

我想设计一个滑块的样式,这样我就可以为拇指左侧的轨道指定一种颜色,而为拇指右侧的轨道指定不同的颜色。我读了这个答案,但它 ...

回答 1 投票 -1

将多个时间值添加到一个用户表格中

我需要帮助在一个用户表单上显示多个时间值。他们将被列在一个列表框中,并将需要保持静态的记录需要编辑。用户将无法访问...

回答 1 投票 0

当用户控件被重建时,用户控件的自定义属性会失去状态。

我有一个用户控件,其自定义属性如下。[DefaultValue(true)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)] [Description("Gets or set whether the \")...。

回答 3 投票 3

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