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 逆天通用水印扩展篇~新增剪贴板系列 ...
随机推荐
- Allow Zero Length 允许空字符串 ACCESS
http://www.360doc.com/content/11/0118/20/991597_87447868.shtml https://microsoft.public.data.ado.nar ...
- 关于apicloud ios自定义模块引用第三方framework not found for architecture armv7
1 .自定义模块 新建模块必须是静态库 2.使用的第三方framework 必须要把 .h文件开放出来 3.编译要用 真机模式 (上传模块以后,自定义load要编译,用生成的二维码调试) 4. 添加监 ...
- python 安装包查看
pip freeze可以查看已经安装的python软件包和版本 pip list 也可以
- 玩转X-CTR100 l STM32F4 l HC-SR04超声波测距
我造轮子,你造车,创客一起造起来!更多塔克创新资讯[塔克社区 www.xtark.cn ][塔克博客 www.cnblogs.com/xtark/ ] 超声波测距模块HC-SR04可以测量2cm~40 ...
- [转]TFS.VisualStudio.com TF30063: You are not authorized to access Collection
If you are trying to connect to team foundation server online through visual studio and you get unau ...
- Cross-Site Script
Cross-Site Script(跨站脚本)XSS 整理于<浅析XSS(Cross Site Script)漏洞原理> 了解XSS的触发条件就先得从HTML(超文本标记语言)开始,我 ...
- Linux Mint KDE上安装fcitx+sougou输入法
今天在韩总废弃的笔记本上安装了Linux Mint系统,装好之后第一件想到的事情就是安装个输入法,由于之前系统自带的输入法框架是ibus,我试用了一下发现很不人性化,所以决定换上fcitx+sougo ...
- 3.3 shell控制流结构
shell中的控制流包括if then else语句,case语句,for循环,until循环,while循环,break控制,continue控制. 条件测试: 有时判断字符串是否相等或检查文件状态 ...
- TI AM335x Linux MUX hacking
/********************************************************************************************* * TI ...
- CodeForces - 1098.DIV1.C: Construct a tree(贪心,构造)
Misha walked through the snowy forest and he was so fascinated by the trees to decide to draw his ow ...