WPF Example: XmlDataProvider & Editable ComboBox
来源:互联网 发布:邓肯数据不怎样 编辑:程序博客网 时间:2024/06/03 22:55
代码如下:
MainWindow.xaml
<Window x:Class="ComboBoxDemo.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="80" Width="329"> <StackPanel Orientation="Horizontal" Width="304"> <StackPanel.Resources> <XmlDataProvider x:Key="dataMemberList" XPath="/MemberList"> <x:XData> <MemberList xmlns=""> <Member> <Name>Stephone</Name> <Id>54765</Id> </Member> <Member> <Name>Alex</Name> <Id>32768</Id> </Member> <Member> <Name>Smith</Name> <Id>44326</Id> </Member> </MemberList> </x:XData> </XmlDataProvider> </StackPanel.Resources> <Label Height="26">Choose/Input member name: </Label> <ComboBox Name="memberNameEditor" Height="24" Width="100" ItemsSource="{Binding Source={StaticResource dataMemberList}, XPath=Member}" DisplayMemberPath="Name" IsEditable="True" /> <Button Height="24" Margin="4,0,4,0" Content="OK" Click="ButtonOK_Click"/> </StackPanel></Window>
MainWindow.xaml.cs
using System.Windows;namespace ComboBoxDemo{ /// <summary> /// Interaction logic for MainWindow.xaml /// </summary> public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void ButtonOK_Click(object sender, RoutedEventArgs e) { MessageBox.Show(this.memberNameEditor.Text); } }}
Notes:
1. 在XmlDataProvider中,必须申明 xmlns="",否则XPath搜索路径会失效;
2. 为了使ComboBox可编辑,需设置 IsEditable="True"。
Vs2010 Solution download: http://download.csdn.net/detail/xinyaping/4356561
- WPF Example: XmlDataProvider & Editable ComboBox
- WPF中XmlDataProvider使用
- WPF数据提供者XmlDataProvider
- Editable Header Table Example
- WPF中使用XmlDataProvider做控件绑定
- WPF ComboBox
- Complete JavaFX 2 Editable Table Example
- WPF在运行时创建动态数据源(XmlDataProvider)
- Editable
- EasyUI里的DataGrid Editable combobox下拉框联动
- WPF Combobox的使用
- WPF Combobox TextSearch使用
- wpf:combobox绑定数据库
- WPF ComboBox Command Binding
- wpf combobox 的使用
- wpf ComboBox设置默认值
- WPF ComboBox 颜色选择器
- WPF 数据绑定 combobox
- CentOS 安装 PHP
- IO流體系學習總結
- 第十六周实验报告2
- 十六周实验一
- jsp cookie遍历
- WPF Example: XmlDataProvider & Editable ComboBox
- 给定一个小数,保留该小数的后两位
- 极小极大搜索方法、负值最大算法和Alpha-Beta搜索方法
- 【Cocoa(mac) Application 开发系列之二】总结一些常用控件以及简单在自定义View上绘制字符串
- PHP文件或目录权限检查函数
- 第十六周作业 1
- C#入门经典学习12-泛型2
- Android OpenGL ES 开发教程(24):Depth Buffer
- Matlab--------mmreader 读avi错误:Initialization failed