ListView是UI库在大多数现代操作系统中提供的图形屏幕控件或窗口小部件,用于以列表形式显示项目。
C# VirtualMode 下的 ListView 当所选项目不可见时闪烁
我知道这听起来很复杂,但请跟着我: 您有一个 VirtualMode = true 的 ListView。 选择一个项目,向下滚动,使所选项目超出可视区域,然后...
我有以下 ListView,我希望将其绑定到我的视图模型中的自定义列表: 我有以下 ListView,我希望将其绑定到我的视图模型中的自定义列表: <ListView x:Name="listviewPlayers" ItemsSource="{Binding Players}" Height="200"> <ListView.View> <GridView> <GridViewColumn Width="235"> <GridViewColumn.Header> <Label Grid.Column="2" Content ="Name" Foreground="Black" FontSize="10"></Label> </GridViewColumn.Header> </GridViewColumn> <GridViewColumn Width="235"> <GridViewColumn.Header> <Label Grid.Column="1" Content ="Score" Foreground="Black" FontSize="10"></Label> </GridViewColumn.Header> </GridViewColumn> <GridViewColumn Width="235"> <GridViewColumn.Header> <Label Grid.Column="0" Content ="Games" Foreground="Black" FontSize="10"></Label> </GridViewColumn.Header> </GridViewColumn> </GridView> </ListView.View> <ListView.ItemTemplate> <DataTemplate DataType="local:MainPageViewModel"> <Grid Height="25"> <Grid.ColumnDefinitions> <ColumnDefinition /> <ColumnDefinition /> <ColumnDefinition /> </Grid.ColumnDefinitions> <Label Content="{Binding Name}" FontWeight="Bold" FontSize="10" Foreground="Black"> </Label> <Label Grid.Column="1" Content="{Binding CurrentScore}" FontSize="10" HorizontalContentAlignment="Center" Foreground="Black"> </Label> <Label Grid.Column="2" Content="{Binding GamesWon}" HorizontalContentAlignment="Center" FontSize="10" Foreground="Black"> </Label> </Grid> </DataTemplate> </ListView.ItemTemplate> </ListView> 在我的视图模型中我有玩家: public ObservableCollection<Player> Players { get { return players; } set { players = value; foreach (Player p in players) { PlayerNames.Add(p.Name); } PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Players")); } } 玩家看起来像这样: public class Player : INotifyPropertyChanged { public event PropertyChangedEventHandler? PropertyChanged; private string name = ""; public string Name { get { return name; } set { name = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Name")); } } private string currentScore = "0"; public string CurrentScore { get { return currentScore; } set { currentScore = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("CurrentScore")); } } private string gamesWon = "0"; public string GamesWon { get { return gamesWon; } set { gamesWon = value; PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("GamesWon")); } } 我的 ListView DataTemplate 绑定做错了什么?我已经在主窗口上设置了这个: d:DataContext="{d:DesignInstance Type=local:MainPageViewModel}" 此时 ListView 看起来像这样: 如有任何建议,我们将不胜感激。 谢谢, 迈克 您不得设置 ListView 的 ItemTemplate 属性。 改为设置 GridViewColumns 的 DisplayMemberBinding 属性。 <ListView x:Name="listviewPlayers" ItemsSource="{Binding Players}" Height="200"> <ListView.View> <GridView> <GridViewColumn Width="235" Header="Name" DisplayMemberBinding="{Binding Name}"/> <GridViewColumn Width="235" Header="Games" DisplayMemberBinding="{Binding CurrentScore}"/> <GridViewColumn Width="235" Header="Score" DisplayMemberBinding="{Binding GamesWon}"/> </GridView> </ListView.View> </ListView>
很抱歉无法提供这个问题的代码,因为我仍处于开发的最初阶段。我将尝试创建一个简单的示例来实现我的目标...
我在asp:list视图控件中有以下代码行,如果用户在第二个文本框中输入任何值,在客户端失去焦点事件我需要计算txtTokensReq * txtQty并显示在lblTotalTokens中...
在此输入图像描述 如何使用此视图更改我的项目,例如这张照片。 是图书馆视图还是回收视图? 我想要一份像这张照片一样的物品或回收商列表。 请帮帮我! 我们如何...
WPF 中的 ListView 不显示 ViewModel 静态数据
我正在创建一个小示例,以在 WPF 页面上使用 ViewModel 显示枚举数据。但不知何故它没有显示。 公共类 GameParticipants:IGameParticipants { 公共 int Id{ 得到;放; }
WPF,列表视图。 RenderTargetBitmap - 如何渲染整个ListView,不限于屏幕
我有ListView,它显示一些图片。并非所有图片都在屏幕上(在窗口中)可见。我想做一些类似“联系表”的东西——所有图片。 我从 ListView 中得到了 ScrollViewer,...
我正在开发一个基于 C++ MFC 的应用程序,它通过 IP 获取位置数据,执行一些操作,通过 IP 将其发送回,然后将其输出到列表控件。每个数据包都会被收集、处理并...
我有一个 flutter 应用程序,用户可以将项目添加到存储在 firebase 中的列表中。用户一次最多可以添加 1000 个项目。最初这不是问题,但随着应用程序列表项的数量不断增加
我试图在滚动时保持标题固定,但我无法弄清楚。 这是我的列表视图代码: 我试图在滚动时保持标题固定,但我无法弄清楚。 这是我的ListView代码: <asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1" DataKeyNames="FormSectionSubSectionItemRelID" OnSelectedIndexChanged="ListView1_SelectedIndexChanged"> 这是我的sites.css表CSS代码: table { border-collapse: collapse; border-spacing: 0; margin-top: 0.75em; border: 0 none; } th { font-size: 1.2em; text-align: left; border: none 0px; padding-left: 0; } th a { display: block; position: relative; } th a:link, th a:visited, th a:active, th a:hover { color: #333; font-weight: 600; text-decoration: none; padding: 0; } th a:hover { color: #000; } th.asc a, th.desc a { margin-right: .75em; } th.asc a:after, th.desc a:after { display: block; position: absolute; right: 0em; top: 0; font-size: 0.75em; } th.asc a:after { content: '▲'; } th.desc a:after { content: '▼'; } td { padding: 0.25em 2em 0.25em 0em; border: 0 none; } tr.pager td { padding: 0 0.25em 0 0; } 如果有一个属性我可以更改或更改我的 CSS 代码,那就太好了。 如果您也可以从服务器端获取代码并创建代码演示,这对您解决这个问题将非常有帮助。 但是,只需查看您的代码,看看您如何询问如何尝试在页面顶部修复某些内容,我在您的CSS代码中看到页面顶部有一个绝对定位的元素,我假设您希望滚动时要固定此元素吗? 如果是这种情况,那么您需要将此代码从绝对更改为固定。 th.asc a:after, th.desc a:after { display: block; position: fixed; //fixed will not scroll with the page, where absolute will. right: 0em; top: 0; font-size: 0.75em; } 在引导表上的滚动条的帮助下并修改 LayoutTemplate 就可以完成。必须重写一些引导 CSS 才能使其工作。 <LayoutTemplate> <div> <table border="1" style="width:96.9%; max-width:100%; background-color:#FFFFFF; border-collapse:collapse; border-color:#999999; border-style:none; border-width:1px; font-family:Verdana, Arial, Helvetica, sans-serif;"> <thead> <tr> <th style="width:8%; background-color: #E0FFFF; color: #333333;" >Car Number</th> <th style="width:7%; background-color: #E0FFFF; color: #333333;" >License Number</th> <th style="width:9%; background-color: #E0FFFF; color: #333333;" >Make</th> <th style="width:8%; background-color: #E0FFFF; color: #333333;" >Model</th> <th style="width:7%; background-color: #E0FFFF; color: #333333;" >Current Miles</th> <th style="width:7%; background-color: #E0FFFF; color: #333333;" >Oil Change Date</th> <th style="width:7%; background-color: #E0FFFF; color: #333333;" >Oil Change Miles</th> <th style="width:7%; background-color: #E0FFFF; color: #333333;" >Tire Rotation Miles</th> <th style="width:7%; background-color: #E0FFFF; color: #333333;" >Last Wash Date</th> <th style="width:6%; background-color: #E0FFFF; color: #333333; text-align:center;" >Location</th> <th style="width:4%; background-color: #E0FFFF; color: #333333; text-align:center;" >Active</th> <th style="width:5%; background-color: #E0FFFF; color: #333333; text-align:center;" >New Oil Change</th> <th style="width:12%; background-color: #E0FFFF; color: #333333;" >Oil Type</th> <th style="width:auto; border-right:none; border-top:none;"></th> </tr> </thead> </table> </div> <div style="width:100%; overflow:auto; max-height:450px;"> <table border="1" style="width:98%; max-width:100%; background-color:#FFFFFF; border-collapse:collapse; border-color:#999999; border-style:none; border-width:1px; font-family: Verdana, Arial, Helvetica, sans-serif;"> <tr runat="server" id="itemPlaceholder"></tr> </table> </div> </LayoutTemplate>
当我运行程序时,第二个表单仅打开半秒钟。我是编码新手,尤其是 C# 新手。我的目标是有一个列表视图,我可以在其中添加“商品”和“补充...
当项目数为0时,我需要动态隐藏我的ListView。 ListView 有项目。我可以使用按钮删除该项目并更新列表。但我想隐藏列表并显示一个 TextView w...
我试图向用户显示一个对话框,其中包含一个列表。无论我如何尝试,它都不会显示在对话框中。 代码: 这是在 TaskInputActivity 中,我在其中创建对话框和适配器
ListView 无法通过 ASP.net C# 中的 SQL 选择查询正确提供数据
我有一个 ASP.net C# 站点。我用这段代码将其中一个 ListView 提供给它,它就可以工作: 受保护的无效 BindData() { 字符串forwardedSearchText = Request.QueryString["SearchText"];...
我想向用户显示带有缩略图和音乐标题的音乐项目,但它无法按我的预期工作。我有相同的代码和不同的列表,它在那里工作,但不知何故它不起作用...
我正在尝试使用 ListTile 构建 ListView 代码在这里: 列表 isRed2 = [ 真,真,假,假, 真,真,真,假, 假,假,真,真, 假,真,真,真, 真的,];
我正在寻求帮助....如何解决这个问题。 我尝试创建一个应用程序,当您单击按钮时显示信息列表。 如果列表要显示在与调用相同的布局上
从 Windows 窗体到 WPF 是一个挑战,这是我的第一个 WPF 项目,所以如果我遗漏了一些明显的东西,请原谅我...... 我正在逐行向 ListView 添加项目,然后想要
请参阅下面的我的代码。这会生成一个包含所有可用 wifi 连接的列表视图。 我的目标是连接到列出的可用连接之一。 我已经尝试了几种方法,但它不起作用...