当前位置: 首页 > news >正文

自做网站打开速度慢网上书城网站开发

自做网站打开速度慢,网上书城网站开发,网站开发实训意义,陕西省住房和建设厅官方网站此示例演示如何绑定到枚举。 遗憾的是#xff0c;没有直接方法可以将枚举用作数据绑定源。 但是#xff0c;Enum.GetValues(Type) 方法可返回值的集合。 这些值可以包装在 ObjectDataProvider 中并用作数据源。 ObjectDataProvider 类型提供了一种在 XAML 中创建对象并将其用…此示例演示如何绑定到枚举。 遗憾的是没有直接方法可以将枚举用作数据绑定源。 但是Enum.GetValues(Type) 方法可返回值的集合。 这些值可以包装在 ObjectDataProvider 中并用作数据源。 ObjectDataProvider 类型提供了一种在 XAML 中创建对象并将其用作数据源的便捷方式。使用 ObjectDataProvider  类型包装枚举类型本身提供的枚举值数组。 ObjectDataProvider x:KeyDirectionEnumDataSource ObjectType{x:Type sys:Enum} MethodNameGetValuesObjectDataProvider.MethodParametersx:Type TypeNamelocal:DirectionType/x:Type/ObjectDataProvider.MethodParameters/ObjectDataProvider 在此示例中ObjectDataProvider 使用三个属性来检索枚举 属性描述ObjectType数据提供程序要返回的对象类型。 在本示例中为 System.Enum。 sys: XAML 命名空间映射到 System。MethodName要在 System.Enum 类型上运行的方法的名称。 在本示例中为 Enum.GetValues。MethodParameters要提供给 MethodName 方法的值的集合。 在此示例中该方法采用枚举的 System.Type。 实际上XAML 正在分解方法调用、方法名称、参数和返回类型。 这里配置的ObjectDataProvider等效于一下代码 var DirectionEnumDataSource System.Enum.GetValues(typeof(EnumBinding.DirectionType)); 引用ObjectDataProvider资源 ListBox ItemsSource{Binding Source{StaticResource DirectionEnumDataSource}} SelectedIndex0/ComboBox ItemsSource{Binding Source{StaticResource DirectionEnumDataSource}} SelectedIndex0/ 或通过代码的方式 ListBox x:NameMyListBox/ListBoxComboBox x:NameMyComboBox/ComboBox MyListBox.ItemsSource System.Enum.GetValues(typeof(DirectionType));MyComboBox.ItemsSource System.Enum.GetValues(typeof(DirectionType)); 完整测试代码 MainWindow.xaml Window x:ClassEnumBinding.MainWindowxmlnshttp://schemas.microsoft.com/winfx/2006/xaml/presentationxmlns:xhttp://schemas.microsoft.com/winfx/2006/xamlxmlns:dhttp://schemas.microsoft.com/expression/blend/2008xmlns:mchttp://schemas.openxmlformats.org/markup-compatibility/2006xmlns:localclr-namespace:EnumBindingxmlns:sysclr-namespace:System;assemblymscorlibmc:IgnorabledTitleMainWindow Height450 Width800Window.ResourcesObjectDataProvider x:KeyDirectionEnumDataSource ObjectType{x:Type sys:Enum} MethodNameGetValuesObjectDataProvider.MethodParametersx:Type TypeNamelocal:DirectionType/x:Type/ObjectDataProvider.MethodParameters/ObjectDataProvider/Window.ResourcesStackPanelListBox ItemsSource{Binding Source{StaticResource DirectionEnumDataSource}} SelectedIndex0/ComboBox ItemsSource{Binding Source{StaticResource DirectionEnumDataSource}} SelectedIndex0/ListBox x:NameMyListBox/ListBoxComboBox x:NameMyComboBox/ComboBox/StackPanel /WindowMainWindow.xaml.cs using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes;namespace EnumBinding;public enum DirectionType : int {Buy 0,Sell 1, }public partial class MainWindow : Window {public MainWindow(){InitializeComponent();MyListBox.ItemsSource System.Enum.GetValues(typeof(DirectionType));MyComboBox.ItemsSource System.Enum.GetValues(typeof(DirectionType));} }
http://www.sadfv.cn/news/162069/

相关文章:

  • 用html5做的简单的网站深圳建设集团怎么样
  • 哪些免费的网站可以做企业宣传不是用于制作网页的软件
  • 有哪些做软件的网站凡科做网站友情链接怎么做
  • 哪个是网站建设里面的服务器可以放几个网站
  • 网站建设攵金手指科杰壹陆怎么恢复网站数据库文件位置
  • 三桥做网站在中国做外国网站怎么收钱
  • 好的企业网站设计方案网站怎么做是满屏
  • 科技网站 石家庄基于android的app开发步骤
  • 新网站建设平台wordpress 文章 字体
  • 行业网站运营策划方案免费网站
  • 易语言做自动登陆网站教程推广优化网站排名
  • 网站建站工具j2ee 网站开发
  • 代做外国空间网站响应式网页设计最方便快速
  • 现在做个网站大概多少钱wordpress评论采集插件
  • 自己做网站用花钱吗企业管理专业学什么
  • 网站开发string文件工作室网站需要备案吗
  • 服务器搭建网站空间简洁wordpress
  • 自己建立的网站网站开发的热门博客
  • 做资源网站赚钱吗wordpress过滤机制
  • 惠州高端网站建设服务短网址api接口
  • 商城网站支付端怎么做wordpress 性能
  • 建设项目环评验收网站体育类网站开发
  • 汕头seo网站排名网站的网站制作
  • 有做销售产品的网站淘宝客如何做淘宝客网站
  • 免费ftp服务器申请网站seo网站结构图
  • 做网站一个人可以吗wordpress 第三方登录
  • 杭州网站优化网站建设具体要求
  • 徐州做网站需要多少钱网站空间搭建
  • 网站建设面谈话术wordpress4.6手册 chm
  • 无锡本地做网站手机网站跟pc网站有什么不同