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

信丰县建设局网站他达那非片能延时多久

信丰县建设局网站,他达那非片能延时多久,武进网站建设好么,南宁做网站费用工业控制中,经常会需要把一个bool 型输入信号的状态显示在面板上,使用wpf 绑定的办法,可简洁实现: 实现步骤: 1,定义类: using System; using System.Collections.Generic; using System.Com…

工业控制中,经常会需要把一个bool  型输入信号的状态显示在面板上,使用wpf 绑定的办法,可简洁实现:

实现步骤:

1,定义类:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;namespace WpfAppBoolBinding
{public class MainViewModel : INotifyPropertyChanged{private bool _myProperty;public bool MyProperty{get { return _myProperty; }set{if (_myProperty != value){_myProperty = value;OnPropertyChanged();}}}public event PropertyChangedEventHandler PropertyChanged;protected virtual void OnPropertyChanged([CallerMemberName] string propertyName = ""){if (this.PropertyChanged != null){this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));}}}public class TestViewModel{public MainViewModel MainView { get; set; }public int couter { get; set; }}
}

2,定义bool  类型转换器:

using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using System.Windows.Media;namespace WpfAppBoolBinding
{[ValueConversion(typeof(bool), typeof(Brush))]public class BooleanToBrushConverter : IValueConverter{public object Convert(object value, Type targetType, object parameter, CultureInfo culture){return (bool)value ? Brushes.Green : Brushes.Red;}public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture){throw new NotImplementedException();}}}

3,xml 实现:

<Window x:Class="WpfAppBoolBinding.MainWindow"xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"xmlns:d="http://schemas.microsoft.com/expression/blend/2008"xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"xmlns:local="clr-namespace:WpfAppBoolBinding" mc:Ignorable="d"Title="MainWindow" Height="450" Width="800"><Window.Resources><local:BooleanToBrushConverter x:Key="BooleanToBrushConverter"/></Window.Resources><Grid><StackPanel HorizontalAlignment="Center" VerticalAlignment="Center"><Ellipse Width="50" Height="50" Fill="{Binding MainView.MyProperty, Converter={StaticResource BooleanToBrushConverter}}" Margin="10,30"/><Button Content="变换颜色" Width="60" Height="30" Click="Button_Click" Margin="10,30"/></StackPanel></Grid>
</Window>

4,进行Datacontex 绑定:

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 WpfAppBoolBinding
{/// <summary>/// MainWindow.xaml 的交互逻辑/// </summary>public partial class MainWindow : Window{TestViewModel testViewModel = new TestViewModel();public MainWindow(){InitializeComponent();testViewModel.MainView = new MainViewModel();DataContext = testViewModel;}private void Button_Click(object sender, RoutedEventArgs e){testViewModel.MainView.MyProperty = !testViewModel.MainView.MyProperty;}}
}

http://www.ds6.com.cn/news/29717.html

相关文章:

  • 网站备案 有效期设计师培训班多少钱
  • 网站模型怎么做整合营销传播策划方案
  • 嘉定企业网站开发建设竞价推广sem
  • 石家庄网站建设q.479185700棒湖南网站建设平台
  • 四川住房和城乡建设部官方网站网站推广技巧和方法
  • 网站做视频好不好百度网站下载安装
  • 肇庆专业网站建设公司seo整站优化多少钱
  • 贵港网站建设seo资源咨询
  • 海盐网站建设长沙企业关键词优化
  • 镇江网站建设价格天猫店铺申请条件及费用
  • 深圳微网站建设优化神马排名软件
  • 都匀市住房和城乡建设局网站seo网络培训机构
  • 福州专业网站建设推广费用泉州关键词排名工具
  • 免费手机网站空间百度网盘seo优化
  • 秦皇岛市建设局网站长沙优化网站厂家
  • 南京小程序制作公司学校seo推广培训班
  • 宁海哪家做网站比较可靠学seo优化
  • 个人注册域名网站怎么做百度在线咨询
  • 山东建设和城乡建设厅注册中心网站首页徐州自动seo
  • 房屋室内设计seo推广工具
  • 网站域名改了以后新域名301网址域名
  • 自己做网站平台需要服务器seo培训师
  • 建设银行河北招聘网站互联网关键词优化
  • 网站建设的流程是什么李勇seo的博客
  • 中国建设工程协会标准网站建站开发
  • lisp 网站开发电商怎么做?如何从零开始学做电商赚钱
  • 黑白的网站网络营销的特点不包括
  • 软件开发流程详细解读seo个人博客
  • 网站是做java还是c竞价广告推广
  • 网站建设专员海口网站排名提升