当前位置: 首页 > news >正文

国外好的做电视包装的网站官方制作网站

国外好的做电视包装的网站,官方制作网站,微商网站推广,域名收录提交入口为 ListView 控件的内容指定视图模式的方法,参考官方文档。 ComboBox 样式和模板 案例说明:通过checkBox和ComboBox的组合方式实现下拉窗口的多选方式,同时说明了ListView中Items项目的两种绑定方式. 示例: 设计样式 Xaml代码…

为 ListView 控件的内容指定视图模式的方法,参考官方文档。

ComboBox 样式和模板

案例说明:通过checkBox和ComboBox的组合方式实现下拉窗口的多选方式,同时说明了ListView中Items项目的两种绑定方式.

示例:

设计样式

Xaml代码 

<Window x:Class="ComboBox自定义多选.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:ComboBox自定义多选"xmlns:hc="https://handyorg.github.io/handycontrol"        mc:Ignorable="d"Title="MainWindow"Height="450"Width="800"Background="DarkGray"><Grid><Grid.ColumnDefinitions><ColumnDefinition Width="300"></ColumnDefinition><ColumnDefinition></ColumnDefinition></Grid.ColumnDefinitions><StackPanel><!-- 定义多选ComboBox --><ComboBox Name="multiSelectComboBox"Width="200"Height="30"HorizontalAlignment="Left" IsEditable="True"StaysOpenOnEdit="True"IsReadOnly="True"Text="多选列表"Margin="10"><!-- 定义ComboBox的ItemTemplate,包含一个CheckBox --><ComboBox.ItemTemplate><DataTemplate><CheckBox Content="{Binding Name}"IsChecked="{Binding IsSelected, Mode=TwoWay}" /></DataTemplate></ComboBox.ItemTemplate></ComboBox><!-- 按钮显示所选项目 --><Button Content="查看选择了什么选项"Width="170"Height="30"VerticalAlignment="Top"HorizontalAlignment="Left"Margin="10"Click="ShowSelectedOptions_Click" /><TextBlock Name="SelectItems"Margin="10"></TextBlock></StackPanel><WrapPanel Grid.Column="1"><ListView Name="StudentList" Margin="10"><ListView.View><GridView><GridViewColumn Header="姓名"                                        Width="200"DisplayMemberBinding="{Binding Name}"></GridViewColumn><GridViewColumn Header="年龄"Width="200"DisplayMemberBinding="{Binding Age}"></GridViewColumn></GridView></ListView.View></ListView><Button Name="Mode1"Margin="10"HorizontalAlignment="Left"Content="方式一"Click="Mode1_Click"></Button><Button Name="Mode2"Margin="10"HorizontalAlignment="Left"Content="方式二"Click="Mode2_Click"></Button></WrapPanel></Grid>
</Window>

CS代码 

using System.Collections.ObjectModel;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;namespace ComboBox自定义多选
{/// <summary>/// Interaction logic for MainWindow.xaml/// </summary>public partial class MainWindow : Window{public ObservableCollection<Student> Items { get; set; }public MainWindow(){InitializeComponent();// 初始化选项集合Items = new ObservableCollection<Student>{new Student { Name = "张三", Age = "20"},new Student { Name = "李四", Age = "21"},new Student { Name = "王五", Age = "22"},new Student { Name = "赵六", Age = "23"}};// 将Items集合绑定到ComboBox的ItemsSourcemultiSelectComboBox.ItemsSource = Items;           }// 显示已选择的选项private void ShowSelectedOptions_Click(object sender, RoutedEventArgs e){// 获取所有IsSelected为true的项目var selectedItems = Items.Where(item => item.IsSelected).Select(item => item.Name).ToList();// 显示选择的项目SelectItems.Text = "你选择了: " + string.Join(", ", selectedItems);}// 数据项类public class Student{public string? Name { get; set; }public string? Age {  get; set; }public bool IsSelected { get; set; }}private void Mode1_Click(object sender, RoutedEventArgs e){StudentList.Items.Clear();// 初始化选项集合Items = new ObservableCollection<Student>{new Student { Name = "张三", Age = "20"},new Student { Name = "李四", Age = "21"},new Student { Name = "王五", Age = "22"},new Student { Name = "赵六", Age = "23"}};// 将Items集合绑定到ListView的ItemsSourceStudentList.ItemsSource = Items;}private void Mode2_Click(object sender, RoutedEventArgs e){StudentList.ItemsSource = null;StudentList.Items.Clear();StudentList.Items.Add(new Student { Name = "孙悟空", Age = "10000" });StudentList.Items.Add(new Student { Name = "悟能", Age = "5000" });StudentList.Items.Add(new Student { Name = "悟净", Age = "3000" });StudentList.Items.Add(new Student { Name = "唐僧", Age = "30" });}}
}

使用效果展示

启动页面

点击“方式一”

点击“方式二”

查看多选框的下拉菜单

 选择两个项目

点击“查看选择了什么选项”

http://www.yayakq.cn/news/424087/

相关文章:

  • 专业做网站公司排名抓取网站访客qq
  • 旅行社网站建设需求分析网页设计购物网站建设
  • wordpress 精彩台州网站建设seo
  • 什么是响应式网站建设dz地方门户网站制作
  • 嘉兴信息网站莱芜红石公园灵异事件
  • 网站建设 南昌漳州市网站建设费用
  • 自己做的网站怎么嵌入高德地图打开现场直播
  • 电子商务网站建设的心得体会手机做网站对比路由器做网站
  • php黄页系统无锡seo优化
  • 推荐专业的网站建设公司网站搭建需要多少钱
  • 有域名怎么建立网站网站建设与维护 书
  • 浏览网站模板个人网页背景图片
  • 如何选择合肥网站建设老客户网站建设
  • 男做直播网站国内网站建设公司top20
  • 内涵图网站源码城市建设鹤岗市网站
  • 刷赞网站推广免费链接google海外推广
  • 杭州seo网站建设免费视频素材库app
  • 唐山网站制作价格电子商务网站建设与制作
  • 外贸网站有哪些?wordpress编辑器经典
  • 专业的做网站公司手机银行app下载安装
  • 网站建设商务代表故事做网站有自己的服务器吗
  • 网站页面设计报告在线设计印章
  • 长沙网站优化内推网站
  • 有限公司网站建设 中企动力重庆赣州seo排名
  • ppt下载模板免费网站衡水网站建设衡水网站建设
  • wordpress导航栏图标郑州seo外包顾问热狗
  • 国内单页面网站高清直播
  • 网站建设用到什么软件网站域名怎么做变更
  • 设计制作一个企业类型网站怎么做私人彩票网站
  • 中盛浩瀚建设有限公司网站装修设计装饰公司