WPF Demo5
<Application x:Class="Demo5.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
StartupUri="MainWindow.xaml"> <!--StartupUri="MainWindow.xaml" 启动页-->
<Application.Resources> </Application.Resources>
</Application>
<Window x:Class="Demo5.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<XmlDataProvider x:Key="xmlData" XPath="/countries/country">
<!-- 示例数据 -->
<x:XData>
<countries xmlns=""> <country name="中国">
<province name="陕西">
<city>西安</city>
<city>宝鸡</city>
</province>
<province name="山西">
<city>太原</city>
<city>大同</city>
</province>
<province name="内蒙古自治区">
<city>呼和浩特</city>
<city>包头</city>
<city>集宁</city>
</province>
<province name="河北">
<city>石家庄</city>
<city>保定</city>
</province>
</country> <country name="美国">
<province name="加利福尼亚">
<city>洛杉矶</city>
<city>圣迭戈</city>
</province>
<province name="福罗里达">
<city>杰克逊维尔</city>
<city>迈阿密</city>
</province>
</country> </countries>
</x:XData>
</XmlDataProvider> <Style TargetType="HeaderedContentControl">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="HeaderedContentControl">
<DockPanel>
<Border DockPanel.Dock="Top" Margin="3" CornerRadius="3" Background="DarkRed">
<TextBlock Text="{TemplateBinding Header}" HorizontalAlignment="Center" Foreground="White"/>
</Border>
<ContentPresenter ContentSource="Content" ContentTemplate="{TemplateBinding ContentTemplate}"/>
</DockPanel>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style> <Style TargetType="ListBoxItem">
<Setter Property="SnapsToDevicePixels" Value="true"/>
<Setter Property="OverridesDefaultStyle" Value="true"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="ListBoxItem">
<Border Name="Border" Padding="2" SnapsToDevicePixels="true">
<ContentPresenter />
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsSelected" Value="true">
<Setter TargetName="Border" Property="Background" Value="YellowGreen"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style> </Window.Resources>
<Grid DataContext="{Binding Source={StaticResource xmlData}}">
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions> <HeaderedContentControl Header="国家">
<ListBox ItemsSource="{Binding}" DisplayMemberPath="@name" IsSynchronizedWithCurrentItem="True"/>
</HeaderedContentControl> <HeaderedContentControl Header="省/州" Grid.Column="1">
<ListBox Name="lbxProvince" ItemsSource="{Binding XPath=province}"
DisplayMemberPath="@name" IsSynchronizedWithCurrentItem="True"/>
</HeaderedContentControl> <HeaderedContentControl Header="城市" Grid.Column="2">
<ListBox DataContext="{Binding ElementName=lbxProvince, Path=SelectedItem}"
ItemsSource="{Binding XPath=city}"
IsSynchronizedWithCurrentItem="True"/>
</HeaderedContentControl>
</Grid>
</Window>
运行效果如下:

WPF Demo5的更多相关文章
- 在WPF中使用依赖注入的方式创建视图
在WPF中使用依赖注入的方式创建视图 0x00 问题的产生 互联网时代桌面开发真是越来越少了,很多应用都转到了浏览器端和移动智能终端,相应的软件开发上的新技术应用到桌面开发的文章也很少.我之前主要做W ...
- MVVM框架从WPF移植到UWP遇到的问题和解决方法
MVVM框架从WPF移植到UWP遇到的问题和解决方法 0x00 起因 这几天开始学习UWP了,之前有WPF经验,所以总体感觉还可以,看了一些基础概念和主题,写了几个测试程序,突然想起来了前一段时间在W ...
- MVVM模式解析和在WPF中的实现(六) 用依赖注入的方式配置ViewModel并注册消息
MVVM模式解析和在WPF中的实现(六) 用依赖注入的方式配置ViewModel并注册消息 系列目录: MVVM模式解析和在WPF中的实现(一)MVVM模式简介 MVVM模式解析和在WPF中的实现(二 ...
- MVVM模式解析和在WPF中的实现(五)View和ViewModel的通信
MVVM模式解析和在WPF中的实现(五) View和ViewModel的通信 系列目录: MVVM模式解析和在WPF中的实现(一)MVVM模式简介 MVVM模式解析和在WPF中的实现(二)数据绑定 M ...
- MVVM设计模式和WPF中的实现(四)事件绑定
MVVM设计模式和在WPF中的实现(四) 事件绑定 系列目录: MVVM模式解析和在WPF中的实现(一)MVVM模式简介 MVVM模式解析和在WPF中的实现(二)数据绑定 MVVM模式解析和在WPF中 ...
- MVVM模式解析和在WPF中的实现(三)命令绑定
MVVM模式解析和在WPF中的实现(三) 命令绑定 系列目录: MVVM模式解析和在WPF中的实现(一)MVVM模式简介 MVVM模式解析和在WPF中的实现(二)数据绑定 MVVM模式解析和在WPF中 ...
- MVVM模式和在WPF中的实现(二)数据绑定
MVVM模式解析和在WPF中的实现(二) 数据绑定 系列目录: MVVM模式解析和在WPF中的实现(一)MVVM模式简介 MVVM模式解析和在WPF中的实现(二)数据绑定 MVVM模式解析和在WPF中 ...
- MVVM模式和在WPF中的实现(一)MVVM模式简介
MVVM模式解析和在WPF中的实现(一) MVVM模式简介 系列目录: MVVM模式解析和在WPF中的实现(一)MVVM模式简介 MVVM模式解析和在WPF中的实现(二)数据绑定 MVVM模式解析和在 ...
- 逆天通用水印支持Winform,WPF,Web,WP,Win10。支持位置选择(9个位置 ==》[X])
常用技能:http://www.cnblogs.com/dunitian/p/4822808.html#skill 逆天博客:http://dnt.dkil.net 逆天通用水印扩展篇~新增剪贴板系列 ...
随机推荐
- 3.strcpy使用注意(3)
void test3(char * str1) { if(str1==NULL) { return; } char string[10]; if(strlen(str1)<=10) { strc ...
- CodeIgniter $this->db->where()的自定义语句写法问题
.自定义字符串:你可以手动的编写子句:$where = "name='Joe' AND status='boss' OR status='active'"; $this->d ...
- git 添加review的相关操作
git主机上涉及到的操作: 185 git branch 186 git pull 187 git branch 188 git checkout -b wangcheng 189 git log 1 ...
- 如何在ubuntu16上安装docker
自从用了docker,就一直无法忘怀,省去了很多部署成本.特别是可以统一开发环境和部署环境,在实际开发中有很大的实用价值. 作为一个伪全栈,我是力推大家学习docker技术的.这种共享linux内核的 ...
- android开源项目集合
ZXing http://code.google.com/p/zxing/ 条形码.二维码 K-9 Mail http://code.google.com/p/k9mail/ 邮件客户端 Sipdro ...
- Python读取ini配置文件的方式
python configparser模块 ConfigParser模块在python中用来读取配置文件,配置文件的格式跟windows下的ini配置文件相似,可以包含一个或多个节(section ...
- grafana的一些坑
坑1: 在设置alert的时候template中的变量是不被支持的,警告如下: 解决办法: 使用不带变量的具体sql查询 坑2: 时间轴的设置: 在更早的版本中时间轴的locale是无法设置的,就是说 ...
- Java快速排序和归并排序详解
快速排序 概述 快速排序算法借鉴的是二叉树前序遍历的思想,最终对数组进行排序. 优点: 对于数据量比较大的数组排序,由于采用的具有二叉树二分的思想,故排序速度比较快 局限 只适用于顺序存储结构的数据排 ...
- ldconfig
#ldconfig# http://www.cnblogs.com/lyongde/p/4190588.html ldconfig是一个动态链接库管理命令,为了让动态链接库为系统所共享,还需运行动态链 ...
- opencv-python教程学习系列13-图像平滑
前言 opencv-python教程学习系列记录学习python-opencv过程的点滴,本文主要介绍图像平滑,坚持学习,共同进步. 系列教程参照OpenCV-Python中文教程: 系统环境 系统: ...