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 逆天通用水印扩展篇~新增剪贴板系列 ...
随机推荐
- linux processes
So that Linux can manage the processes in the system, each process is represented by a task_struct ...
- 快速切题 sgu119. Magic Pairs
119. Magic Pairs time limit per test: 0.5 sec. memory limit per test: 4096 KB “Prove that for any in ...
- Oracle 从共享池删除指定SQL的执行计划
ORACLE从共享池删除指定SQL的执行计划 2016-12-29 11:14 by 潇湘隐者, 2836 阅读, 0 评论, 收藏, 编辑 Oracle 11g在DBMS_SHARED_POOL包中 ...
- log4j 将日志文件输出到web-inf下的解决办法
参考链接:http://blog.csdn.net/chenfengdejuanlian/article/details/70738995 只需要配置好即可,用的时候直接在代码中获得记录器记录,监听器 ...
- python 元组(tuple)
面试python我想每个人都会被问一个问题,就是python中的list和tuple有什么区别? 一般情况下,我会回答,list元素可变,tuple元素不可变(书上或者其他的博客都是这么写的),一般情 ...
- 教你如何打开android4.3和4.4中隐藏的AppOps
注:下面的方法在4.4.2更新后已失效! PreferenceActivity的switchToHeaderInner()函数中会调用isValidFragment函数来检查fragment是否合法. ...
- SharePoint 2013的100个新功能之内容管理(三)
一:视频中的人 作为视频内容类型的一部分,一个新的栏"视频中的人"被加入到其中,可以指定视频中的人,作为视频的元数据.当你编辑视频属性时可以查看到该栏.更多信息 二:重建索引 一个 ...
- avalon 路由问题
1, 直接使用avalon的 amd加载器, 可以不需要 require.js 2, 配置baseUrl 路径, 这个一定要在 js所在的目录, 而不是jsp所在的目录, 如果js 和jsp分开 ...
- ReactNative——UI1.登录界面样式设置
使用React 基本组件结合flex 属性,实现简单登录布局UI 效果 效果预览:
- UML-(团队作业)
UML设计 1.团队信息: 队名:异次元 2.团队成员: 姓名 分配任务 王诚荣(队长) 汇总合并,系统活动图 马祎特 好感度系统类图,电子版图片绘制 陈斌 个人中心,闹钟界面用例图,状态图 洪康 后 ...