listview 相关问题

ListView是UI库在大多数现代操作系统中提供的图形屏幕控件或窗口小部件,用于以列表形式显示项目。

在使用可滚动listview.builder(颤振)时使用单个singlechildscrollview

这是我的整个代码: 导入“包:flutter/material.dart”; 导入'包:testproject/components/event_tile.dart'; 导入'包:testproject/components/mybutton.dart'; 类 MenuPage 扩展

回答 1 投票 0

无法显示列表视图内容

我正在开发 MAUI Windows 桌面应用程序。 我的列表视图有问题。 在我向数据库发出请求后,我的数据已正确加载。在本例中,我有一个包含 8 个对象的列表。 前面的列表视图是

回答 1 投票 0

WPF - 使用 ContextMenu、MVVM 和 Command 将 ListView 的项目单元格文本复制到剪贴板

我试图实现一个非常简单的任务:使用右键单击上下文菜单将 ListView 单元格的文本复制到剪贴板,但该任务在 WPF 中似乎非常复杂。我读过几个主题...

回答 1 投票 0

javafx listview自动滚动到末尾

我正在使用 JavaFX ListView 作为我的聊天应用程序的聊天室主体。当消息到来或正在发送时,我将添加到列表视图。这很有效,但我总是必须滚动才能找到最新的...

回答 3 投票 0

MAUI:Refreshview 内的 Listview 完全伸展并滚动整个 UI

带有标签、搜索栏、按钮和列表视图的 UI 垂直布局。这个 UI 可以在没有 Refreshview 的情况下完美呈现,并且我可以滚动列表中的项目。但是当这些控制被使用时...

回答 1 投票 0

为什么列表视图在 salesforce crm 标准用户中不起作用?

我正在开发 salesforce IT 库存系统,其中我有 2 个配置文件“标准用户”,即克隆名称为“HOD”和“系统管理员”。 有物体“

回答 1 投票 0

MAUI BindingContext 设置为 Binding 时不起作用

在我的主页上,我有一个 MainViewModel,其中包含一些属性,其中一个是 EffectsCtrl (另一个视图模型,EffectsControl 类的实例),其中包含与

回答 4 投票 0

ListView 网格中的网格

我有一个包含 id、名称和价格的列表视图。每个这样的项目都有一个带有类别的子列表。 所以“对于每个”项目我想显示所有子项目。 它应该是这样的: 但我不知道...

回答 3 投票 0

如何在项目添加到列表时通知用户,而无需在 flutter 中刷新整个列表

在flutter中,我有一个listView,它从列表中获取它的项目,并且该列表是从互联网下载的,每当将新项目添加到列表中时,我都会有一个事件告诉应用程序添加了新项目,...

回答 2 投票 0

StickyListHeadersAdapter 定义多个 ColorDrawable 对象并将它们显示为背景色。当使用相同的颜色时,它是有问题的

我自己解决了这个问题,但解决方法激怒了我;我希望这对某人有用。我将在下面发布解决方案... 我正在使用该包 导入 se.emilsjolander.stickylistheaders.

回答 1 投票 0

LinearLayout 不显示所有 ListView,只显示一个孩子

我有一些数据将显示在 ListView 中。问题是一切都很顺利,但 ListView 或 LinearLayout 没有足够的扩展来显示 CustomListV 的所有子项...

回答 1 投票 0

ListView 内容未出现 - Xamarin Forms

我试图显示周列表,每周可以有多个事件和恢复(GroupedWeeksModel 类)。问题是中的内容没有出现,...

回答 1 投票 0

如何在点击 TextField 时仅显示 ListView

我默认在屏幕上显示建议列表,我想让建议列表仅在单击文本字段时显示。 我尝试将 listView 放在集合旁边......

回答 1 投票 0

如何从用户按下的ListTile中获取标题的String值?

我需要 ListTile 中点击的标题的字符串值 这是我的 Listviewbuilder 代码: 展开( 孩子:ListView.builder( itemCount: displayed_add_ingridients_to_...

回答 1 投票 0

使用 SharedPreferences 保存 listView 项目

我想接收用户的列表视图项目。通过按下按钮,编辑文本中的值将被输入到列表中。并保存此列表。这样关闭程序就不会破坏...

回答 1 投票 0

Jetpack Compose:列表更改时更新可组合项

我在屏幕上有一个可组合项,其中显示了轨道项目(收藏夹)的列表: var 最爱:MutableList by mutableStateOf(mutableListOf()) @实验基金会Api @可组合

回答 4 投票 0

Android - 在 Fragments onResume 函数中设置 listView 子级的背景颜色会出现 NullPointerException

我正在构建一个Android应用程序。在我的主要活动中,我有一个 FragmentPageAdpater,我基本上做的是我有这个可重用的 Fragment 类,我实例化了三次。 我的片段...

回答 1 投票 0

如何在WPF中将List绑定到Listview userControl?

我正在尝试使用指定的 userControl UI 创建数据库中产品的 ListView。 这是我的清单。 我正在尝试使用指定的 userControl UI 创建数据库中产品的 ListView。 这是我的清单。 <ListView x:Name="ProductTable" Background="Transparent" ItemsSource="{Binding GetProducts}"> <ListView.ItemTemplate> <DataTemplate> <v:ProductLineStyle/> </DataTemplate> </ListView.ItemTemplate> <ItemsControl></ItemsControl> </ListView> 我尝试通过使用 XAML 代码中的 ItemSource 属性或在代码隐藏中将其绑定到我在代码隐藏中的列表。 ProductTable.Items.Clear(); ProductTable.ItemsSource = GetProducts(); 但我最后总是得到空列表项。 我检查了我想要绑定多次的列表,它不为空。 起初我尝试从ListView更改为ListBox,但它不起作用,我尝试使用userControl后面的代码作为产品类,但似乎userControl的构造函数不应该有参数,所以我使用了另一个上课,因为这样会更容易。 这就是我现在的用户控件中的代码 public ProductLineStyle() { InitializeComponent(); this.DataContext = this; } public string ProductID { get; set; } public string ProductName { get; set; } public int ProductPrice { get; set; } public int ProductQTé { get; set; } 这是 XAML 脚本 <Rectangle HorizontalAlignment="Stretch" RadiusX="10" RadiusY="10" Fill="#2A3E50"> </Rectangle> <DockPanel> <TextBlock x:Name="ID" Text="{Binding ProductID}" FontFamily="Inter Semi Bold" Margin="10" FontSize="20" Foreground="#01161E" VerticalAlignment="Center" Width="130" HorizontalAlignment="Left"/> <TextBlock x:Name="Product" Text="{Binding ProductName}" FontFamily="Inter Semi Bold" Margin="10" MaxWidth="400" FontSize="20" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Left"/> <TextBlock x:Name="Qte" Text="{Binding ProductQTé}" FontFamily="Inter Semi Bold" Width="50" FontSize="20" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Right" DockPanel.Dock="Right" Margin="0,0,10,0"/> <TextBlock x:Name="Price" Text="{Binding ProductPrice}" FontFamily="Inter Semi Bold" Margin="10,10,30,10" MaxWidth="400" FontSize="20" Foreground="White" VerticalAlignment="Center" DockPanel.Dock="Right" HorizontalAlignment="Right"/> </DockPanel> 这是我正在使用的课程。 internal class Product { public Product(string ID, string Name, int Price, int Qty) { ProductID = ID; ProductName = Name; ProductPrice = Price; ProductQTé = Qty; } public string ProductID { get; set; } public string ProductName { get; set; } public int ProductPrice { get; set; } public int ProductQTé { get; set; } } 您必须将ProductLineStyle内的DataTemplate控件与ItemsControl的项目连接起来。您必须将 ProductLineStyle 绑定到 Product 项目。 但是为了能够做到这一点,在 ProductLineStyle 控件中定义的所有属性都必须定义为依赖属性。不允许您将绑定分配给非依赖属性。 接下来,因为 Product 类是绑定源,所以它必须实现 INotifyPropertyChanged。如果不这样做,就会造成内存泄漏。 请勿对ItemsControl.ItemsSource进行操作。而是对源集合进行操作。除此之外, ItesControl.Items.Clear 调用是多余的,只会增加性能成本。它强制集合的完整迭代,以便逐项删除。此操作使用项目索引。这意味着,集合越大,清除集合所需的时间就越长。如果您打算更换集合,则不必事先清除它。 在 WPF 中,您无法绑定到方法。以下代码不起作用: <ListView x:Name="ProductTable" ItemsSource="{Binding GetProducts}" /> 您只能绑定到公共属性。 即使绑定有效,您也可以通过显式代码隐藏赋值来删除/覆盖它: // Overrides the binding declared in XAML ProductTable.ItemsSource = GetProducts(); 使用其中之一。更喜欢数据绑定。 还有另一个重要的细节:永远不要在内部设置控件的 DataContext。特别是当该控件需要在其一个或多个属性上定义 Binding 时。 这将破坏所有外部数据绑定: <Grid> <Grid.DataContext> <Product Id="Abc" /> </Grid.DataContext> <!-- Binding is unexpectedly broken and won't resolve, because the ProductStyle internally changes the value of DataContext: 'DataContext = this;' --> <ProductStyle ProductId="{Binding Id}" /> </Grid> 外部绑定通常针对当前DataContext。没有人预料到这个值会被控件默默地操纵。 关键是依赖属性引擎将自动从父级继承正确的 DataContext 值。 在您的场景中,该父项是 ListBoxItem,继承的值是 Product 项。现在您可以轻松地将 ProductStyle 控件绑定到当前 DataContext,即 Product。绑定将按预期运行 要修复代码,您必须更改类设计和实现。 产品.cs // This type must implement INotifyPropertyChanged. // If this type had been a child of DependencyObject // it would have to implement properties as dependency properties instead. internal class Product : INotifyPropertyChanged { // Use the common and recommend C# naming conventions // which states that fields and parameter names // must use camelCase. PascalCase is only for types and properties and events. public Product(string id) { this.ProductId = id; } protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = null) => this.PropertyChanged?.Invoke(this, new PropertyChangedArgs(propertyName)); public string Id { get; set; } public event PropertyChangedEventHandler PropertyChanged; } MainWindow.xaml.cs partial class MainWindow : Window { public ObservableCollection<Product> Products { get; } public MainWindow() { InitializeComponent(); this.Products = new ObservableCollection<Product> { new Product("A112"), new Product("B543") }; } } MainWindow.xaml <Window> <ListBox ItemsSource="{Binding RelativeSource={RelativeSource AncestorType=Window}, Path=Products}"> <ListBox.ItemTemplate> <ProductLineStyle ProductId="{Binding Id}" /> </ListBox.ItemTemplate> </ListBox> </Window> ProductStyle.xaml.cs class ProductLineStyle : UserControl { public string ProductId { get => (string)GetValue(ProductIdProperty); set => SetValue(ProductIdProperty, value); } public static readonly DependencyProperty ProductIdProperty = DependencyProperty.Register( "ProductId", typeof(string), typeof(MainWindow), new PropertyMetadata(default)); public ProductLineStyle() { InitializeComponent(); // Don't do this. This will break your external data bindings // (the data bindings defined on the ProductStyle element)! // The correct DataContext value will be automatically inherited from the parent. // In this scenario, the parent is the ListBoxItem and the value the Product type. //this.DataContext = this; } } 产品样式.xaml <UserControl> <TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=UserControl}, Path=ProductId}" /> </UserControl>

回答 1 投票 0

Flutter ListView 未更新

我想在 Flutter 中创建一个 ListView,当新数据到达时它会更新。我正在使用 RefreshIndicator 来触发列表加载以进行测试。对于我的列表,我使用 ListBuilder 来映射我的

回答 4 投票 0

如何在 SwiftUI 中的 List 的 .ondelete() 中添加确认

如何向我的deleteRow() 函数添加确认? A 已经添加了 .alert 但我不知道如何继续。 列表 { ForEach(数据, id: \.self) { 项目中 文本(项目) .警报(

回答 4 投票 0

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