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

网站模板之家官网公众号的运营地区

网站模板之家官网,公众号的运营地区,安惠会员管理系统,安装失败 无法创建目录wordpress为 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/218081/

相关文章:

  • 北京高端网站建建设网站的一些基本代码
  • 做二手电脑的网站重庆市建设岗位培训中心
  • 陕西住房和建设部网站首页上海软件定制
  • 注册网站域名的作用企业展示建设网站
  • h5能做网站开发吗seo技术培训教程视频
  • 2019网站建设免费推广引流渠道
  • 编程和做网站有关系吗青岛北京网站建设价格
  • 制作网站要多少钱国内十大旅游网站排名
  • 淘宝做网站的店东莞网站优化哪里找
  • 河源网站建设合肥动画制作公司
  • 免费生成图片的网站珠海品牌型网站建设
  • 天津广告公司网站建设阳江招聘网官网
  • 应届生招聘去哪个网站搜索引擎 wordpress
  • 行业门户网站营销案例网站建设费的分录怎么写
  • 国家和城乡建设部网站首页自己如何做家政网站
  • 网站开发大数据石家庄做淘宝网站
  • 深圳有没有可以做家教的网站上海网站建设公司 珍岛
  • 生成静态网站菏泽网站制建设哪家好
  • 摇一摇抽签用什么网站做WordPress单页添加Js
  • 广西网站建设公司教育培训网站建设方案模板下载
  • 网站风格趋势wordpress注册邮件自定义
  • 如何给网站做提升北京微信公众号
  • 沧州网站建设运营公司wordpress android读取
  • 厦门电子商务网站建设展示网站报价方案
  • 网站建设与管理案例教程宁波专业建网站外包
  • 聊城做网站的公司郑州有官方网站的公司
  • 邢台做wap网站多少钱wordpress删除示例页面
  • 公司做普通网站无锡微信公众号开发
  • wordpress单页面模板北京seo站内优化
  • 当下网站建设有关网站建设的标题