首页 > 其他分享 >深入浅出WPF——P91把子集集合的元素当Path

深入浅出WPF——P91把子集集合的元素当Path

时间:2023-07-14 18:14:41浏览次数:41  
标签:City set Name P91 List Path new WPF public

 public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        
        

            List <Country> countryList = new List<Country>()
            {
                 new Country(){Name="中国",ProvinceList=new List<Province>(){new Province() { Name = "四川省", CityList =new List<City> (){ new City() { Name = "绵阳市" },
                                                                                                                                             new City() { Name = "成都市" }
                                                                                                                                           }
                                                                                          },
                                                                          new Province() { Name = "河南省", CityList =new List<City> () { new City() { Name = "鹤壁市" },
                                                                                                                                          new City() { Name = "郑州市" }
                                                                                                                                         }
                                                                                          }

                                                                          }
        
                 },
                 new Country(){ Name="加拿大",ProvinceList=new List<Province>() {new Province() { Name="安图略",CityList =new List<City> () { new City() { Name = "南安大略省" },
                                                                                                                                              new City() { Name = "北安大略省" }
                                                                                                                                             }
                     }}
                 }



            };


            this.textBox1.SetBinding(TextBox.TextProperty, new Binding("/Name") { Source = countryList });//集合默认元素,即中国
            this.textBox2.SetBinding(TextBox.TextProperty, new Binding("/ProvinceList/Name") { Source = countryList });
            this.textBox3.SetBinding(TextBox.TextProperty, new Binding("/ProvinceList/CityList[1].Name") { Source = countryList });
        }



        public class City
        {
            public string Name { get; set; } 

        }
        public class Province
        {
            public string Name { get; set; }
            public List<City> CityList { get; set; }
        }
        public class Country
        {
            public string  Name { get; set; }
            public List<Province> ProvinceList { get; set; }
        }
    }
}

 

标签:City,set,Name,P91,List,Path,new,WPF,public
From: https://www.cnblogs.com/yuanyuanhi/p/17554676.html

相关文章

  • vim E447: cannot find file iostream in path
    查看c/c++文件中的头文件,可以使用gf跳转,但是有时会出现Error447:notfoundinpath1,命名模式中输入,临时修改:setpath=.,/usr/include,,/usr/include/c++/*/2,修改vimrc增加setpath+=.,/usr/include,,/usr/include/c++/*/......
  • mac git clone error:xcrun:error:invalid active developer path(/Library/Developer
    背景升级Mac系统后,在终端使用gitclone等相关命令失败,报错xcrun:error:invalidactivedeveloperpath(/Library/Developer/CommandLineTools),missingxcrunat:/Library/Developer/CommandLineTools/usr/bin/xcrun1.问题排查1.查看git是否已经安装#命令whichgit#......
  • WPF CheckBox勾选框大小设置
    1、设置CheckBox,FontSize,只有字体发生变化,前面的勾选框太小,可以设置LayoutTransform<StyleTargetType="CheckBox"><SetterProperty="HorizontalAlignment"Value="Left"/><SetterProperty="LayoutTra......
  • java根据组织表中的id parent_id生成 org_path
    Java根据组织表中的idparent_id生成org_path的实现流程1.整体流程为了实现根据组织表中的id和parent_id生成org_path,我们可以按照以下步骤进行操作:步骤操作1获取组织表中的所有数据2创建一个HashMap用于存储每个组织id对应的结果3遍历组织表中的每个组织记......
  • WPF TreeView 检测SelectedItem变化的简单方案
    TreeView无法绑定SelectedItem,而又想知道treeview的selecteditem的变化,当然目前有很多方法,我这里简单的提供一个。目前主要思路就是通过处理xaml的TreeViewItem的IsSelected属性来进行绑定。<TreeViewBorderThickness="0"Width="220"......
  • defined in class path resource [de/codecentric/boot/admin/server/config/AdminSe
    搭建springbootadmin监控时出现的,经排查是版本过低,换个高版本的,顺利进入网页界面<dependency><groupId>de.codecentric</groupId><artifactId>spring-boot-admin-starter-server</artifactId><version>2.7.10</version......
  • WPF获取MainWindows实例
    WPF获取MainWindow实例在其他类中获取MainWindow实例,获取其控件,改变其控件属性等,代码如下:_mainWindow=Application.Current.Windows.Cast<Window>().FirstOrDefault(Window=>WindowisMainWindow)asMainWindow;例如在ConfigureViewModel中改变MainWindow中的某个TextB......
  • 【Azure App Service】Web Job 报错 UNC paths are not supported. Defaulting to Win
    问题描述PHP的WebJob,通过artisan来配置路径启动PHP任务,相关启动脚本如下:artisan_path="d:\\home\\site\\wwwroot";cd${artisan_path}echo"\n"pwdphpartisanschedule:run但是,在运行的时候遇见报错:[07/06/202301:57:31>0f21a2:INFO]/d/home/site/wwwroo......
  • WPF开发中ReactiveUI.Fody的使用
    前面的开发一般我会使用PropertyChanged.Fody,但ReactiveUI.Fody也能实现类似的功能。安装Nuget包Install-PackageReactiveUI.FodyFodyWeavers.xml文件:<Weaversxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"......
  • 管理员权限启动WPF应用程序
    1、添加应用程序清单文件 2、requestedExecutionLevel节点,level属性修改为“requireAdministrator”<requestedExecutionLevellevel="requireAdministrator"uiAccess="false"/> ......