例如在WPF中,对其中的一个CheckBox 由多个CheckBox来触发的
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ARM.Modules.QKMLib
{
class UserAttachModule: INotifyPropertyChanged
{
private bool _GmProtocol;
private bool _GmCmdHandler;
private bool _GmExtmemXfer;
private bool _GmMacroCmd;
private bool _GmSystem;
private bool _GmMotionBlock;
private string _GcCmdResponse;
private bool _GmSerial;
private string _GcDioAdtAdam;
private string _GcDioDamJy;
private string _GcAmpGthd;
private string _GcAmpMsb;
private string _GcBc2Hnw;
private string _GcDgSfj;
private string _GcPlcMsbFx;
private string _GcThmCnCar;
private string _GcMtrMoonMSST5;
private string _GcWeigherYH;
private string _GcUpsSataC6k;
private string _GcLsrKyIl;
private string _GcLcMtdc;
private bool _GmDIOInterface;
private string _GcRbtYsk;
private string _GcBc2Ky;
private string _GcBzer;
private string _GcPlcMsbQ;
private string _GcVfdDltM;
private string _GcPlcOmrCp1l;
private string _GmMath;
private string _GmAccuracyMappingCal;
private string _GmDataLogger;
private string _GmRecipe;
private string _GmUserIF;
private string _GmNvram;
private string _GmInertiaAdjust;
private string _GcHEC;
private string _GcMatrix;
private string _GcMdbs;
private string _GcVotF;
private string _GcWdog;
private string _GcRbtTool;
public UserAttachModule()
{
_GcCmdResponse = "0";
_GcDioAdtAdam = "0";
_GcDioDamJy = "0";
_GcAmpGthd = "0";
_GcAmpMsb = "0";
_GcBc2Hnw = "0";
_GcDgSfj = "0";
_GcPlcMsbFx = "0";
_GcThmCnCar = "0";
_GcMtrMoonMSST5 = "0";
_GcWeigherYH = "0";
_GcUpsSataC6k = "0";
_GcLsrKyIl = "0";
_GcLcMtdc = "0";
_GcRbtYsk = "0";
_GcBc2Ky="0";
_GcBzer = "0";
_GcPlcMsbQ = "0";
_GcVfdDltM = "0";
_GcPlcOmrCp1l = "0";
_GmMath = "0";
_GmAccuracyMappingCal = "0";
_GmDataLogger = "0";
_GmRecipe = "0";
_GmUserIF = "0";
_GmNvram = "0";
_GmInertiaAdjust = "0";
_GcHEC = "0";
_GcMatrix = "0";
_GcMdbs = "0";
_GcVotF = "0";
_GcWdog = "0";
_GcRbtTool = "0";
}
public bool m_GmProtocol
{
get
{
if (_GmExtmemXfer == true)
{
return true;
}
if (_GmMacroCmd == true)
{
return true;
}
if (_GmSystem == true)
{
return true;
}
if (_GmMotionBlock == true)
{
return true;
}
if (_GcCmdResponse != "0")
{
return true;
}
return _GmProtocol;
}
set
{
_GmProtocol = value;
OnPropertyChanged("m_GmProtocol");
}
}
public bool m_GmCmdHandler
{
get
{
if (_GmExtmemXfer == true)
{
return true;
}
if (_GmMacroCmd == true)
{
return true;
}
if (_GmSystem == true)
{
return true;
}
if (_GmMotionBlock == true)
{
return true;
}
if (_GcCmdResponse != "0")
{
return true;
}
return _GmCmdHandler;
}
set
{
_GmCmdHandler = value;
OnPropertyChanged("m_GmCmdHandler");
}
}
public bool m_GmExtmemXfer
{
get
{
return _GmExtmemXfer;
}
set
{
_GmExtmemXfer = value;
OnPropertyChanged("m_GmExtmemXfer");
}
}
public bool m_GmMacroCmd
{
get
{
return _GmMacroCmd;
}
set
{
_GmMacroCmd = value;
OnPropertyChanged("m_GmMacroCmd");
}
}
public bool m_GmSystem
{
get
{
return _GmSystem;
}
set
{
_GmSystem = value;
OnPropertyChanged("m_GmSystem");
}
}
public bool m_GmMotionBlock
{
get
{
return _GmMotionBlock;
}
set
{
_GmMotionBlock = value;
OnPropertyChanged("m_GmMotionBlock");
}
}
public string m_GcCmdResponse
{
get
{
return _GcCmdResponse;
}
set
{
_GcCmdResponse = value;
OnPropertyChanged("m_GcCmdResponse");
}
}
public bool m_GmSerial
{
get
{
if (m_GcDioAdtAdam != "0")
{
return true;
}
if (m_GcDioDamJy != "0")
{
return true;
}
if (m_GcAmpGthd != "0")
{
return true;
}
if (m_GcAmpMsb != "0")
{
return true;
}
if (m_GcBc2Hnw != "0")
{
return true;
}
if (m_GcDgSfj != "0")
{
return true;
}
if (m_GcPlcMsbFx != "0")
{
return true;
}
if (m_GcThmCnCar != "0")
{
return true;
}
if (m_GcMtrMoonMSST5 != "0")
{
return true;
}
if (m_GcWeigherYH != "0")
{
return true;
}
if (m_GcUpsSataC6k != "0")
{
return true;
}
if (m_GcLsrKyIl != "0")
{
return true;
}
if (m_GcLcMtdc != "0")
{
return true;
}
return _GmSerial;
}
set
{
_GmSerial = value;
OnPropertyChanged("m_GmSerial");
}
}
public string m_GcDioAdtAdam
{
get
{
return _GcDioAdtAdam;
}
set
{
_GcDioAdtAdam = value;
OnPropertyChanged("m_GcDioAdtAdam");
}
}
public string m_GcDioDamJy
{
get
{
return _GcDioDamJy;
}
set
{
_GcDioDamJy = value;
OnPropertyChanged("m_GcDioDamJy");
}
}
public string m_GcAmpGthd
{
get
{
return _GcAmpGthd;
}
set
{
_GcAmpGthd = value;
OnPropertyChanged("m_GcAmpGthd");
}
}
public string m_GcAmpMsb
{
get
{
return _GcAmpMsb;
}
set
{
_GcAmpMsb = value;
OnPropertyChanged("m_GcAmpMsb");
}
}
public string m_GcBc2Hnw
{
get
{
return _GcBc2Hnw;
}
set
{
_GcBc2Hnw = value;
OnPropertyChanged("m_GcBc2Hnw");
}
}
public string m_GcDgSfj
{
get
{
return _GcDgSfj;
}
set
{
_GcDgSfj = value;
OnPropertyChanged("m_GcDgSfj");
}
}
public string m_GcPlcMsbFx
{
get
{
return _GcPlcMsbFx;
}
set
{
_GcPlcMsbFx = value;
OnPropertyChanged("m_GcPlcMsbFx");
}
}
public string m_GcThmCnCar
{
get
{
return _GcThmCnCar;
}
set
{
_GcThmCnCar = value;
OnPropertyChanged("m_GcThmCnCar");
}
}
public string m_GcMtrMoonMSST5
{
get
{
return _GcMtrMoonMSST5;
}
set
{
_GcMtrMoonMSST5 = value;
OnPropertyChanged("m_GcMtrMoonMSST5");
}
}
public string m_GcWeigherYH
{
get
{
return _GcWeigherYH;
}
set
{
_GcWeigherYH = value;
OnPropertyChanged("m_GcWeigherYH");
}
}
public string m_GcUpsSataC6k
{
get
{
return _GcUpsSataC6k;
}
set
{
_GcUpsSataC6k = value;
OnPropertyChanged("m_GcUpsSataC6k");
}
}
public string m_GcLsrKyIl
{
get
{
return _GcLsrKyIl;
}
set
{
_GcLsrKyIl = value;
OnPropertyChanged("m_GcLsrKyIl");
}
}
public string m_GcLcMtdc
{
get
{
return _GcLcMtdc;
}
set
{
_GcLcMtdc = value;
OnPropertyChanged("m_GcLcMtdc");
}
}
public bool m_GmDIOInterface
{
get
{
return _GmDIOInterface;
}
set
{
_GmDIOInterface = value;
OnPropertyChanged("m_GmDIOInterface");
}
}
public string m_GcRbtYsk
{
get
{
return _GcRbtYsk;
}
set
{
_GcRbtYsk = value;
OnPropertyChanged("m_GcRbtYsk");
}
}
public string m_GcBc2Ky
{
get
{
return _GcBc2Ky;
}
set
{
_GcBc2Ky = value;
OnPropertyChanged("m_GcBc2Ky");
}
}
public string m_GcBzer
{
get
{
return _GcBzer;
}
set
{
_GcBzer = value;
OnPropertyChanged("m_GcBzer");
}
}
public string m_GcPlcMsbQ
{
get
{
return _GcPlcMsbQ;
}
set
{
_GcPlcMsbQ = value;
OnPropertyChanged("m_GcPlcMsbQ");
}
}
public string m_GcVfdDltM
{
get
{
return _GcVfdDltM;
}
set
{
_GcVfdDltM = value;
OnPropertyChanged("m_GcVfdDltM");
}
}
public string m_GcPlcOmrCp1l
{
get
{
return _GcPlcOmrCp1l;
}
set
{
_GcPlcOmrCp1l = value;
OnPropertyChanged("m_GcPlcOmrCp1l");
}
}
public string m_GmMath
{
get
{
return _GmMath;
}
set
{
_GmMath = value;
OnPropertyChanged("m_GmMath");
}
}
public string m_GmAccuracyMappingCal
{
get
{
return _GmAccuracyMappingCal;
}
set
{
_GmAccuracyMappingCal = value;
OnPropertyChanged("m_GmAccuracyMappingCal");
}
}
public string m_GmDataLogger
{
get
{
return _GmDataLogger;
}
set
{
_GmDataLogger = value;
OnPropertyChanged("m_GmDataLogger");
}
}
public string m_GmRecipe
{
get
{
return _GmRecipe;
}
set
{
_GmRecipe = value;
OnPropertyChanged("m_GmRecipe");
}
}
public string m_GmUserIF
{
get
{
return _GmUserIF;
}
set
{
_GmUserIF = value;
OnPropertyChanged("m_GmUserIF");
}
}
public string m_GmNvram
{
get
{
return _GmNvram;
}
set
{
_GmNvram = value;
OnPropertyChanged("m_GmNvram");
}
}
public string m_GmInertiaAdjust
{
get
{
return _GmInertiaAdjust;
}
set
{
_GmInertiaAdjust = value;
OnPropertyChanged("m_GmInertiaAdjust");
}
}
public string m_GcHEC
{
get
{
return _GcHEC;
}
set
{
_GcHEC = value;
OnPropertyChanged("m_GcHEC");
}
}
public string m_GcMatrix
{
get
{
return _GcMatrix;
}
set
{
_GcMatrix = value;
OnPropertyChanged("m_GcMatrix");
}
}
public string m_GcMdbs
{
get
{
return _GcMdbs;
}
set
{
_GcMdbs = value;
OnPropertyChanged("m_GcMdbs");
}
}
public string m_GcVotF
{
get
{
return _GcVotF;
}
set
{
_GcVotF = value;
OnPropertyChanged("m_GcVotF");
}
}
public string m_GcWdog
{
get
{
return _GcWdog;
}
set
{
_GcWdog = value;
OnPropertyChanged("m_GcWdog");
}
}
public string m_GcRbtTool
{
get
{
return _GcRbtTool;
}
set
{
_GcRbtTool = value;
OnPropertyChanged("m_GcRbtTool");
}
}
public event PropertyChangedEventHandler PropertyChanged;
protected void OnPropertyChanged(string propertyName)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
//判断是否需要开启网络通信模块
if (propertyName == "m_GmExtmemXfer"|| propertyName == "m_GmMacroCmd" ||
propertyName == "m_GmSystem" || propertyName == "m_GmMotionBlock"|| propertyName == "m_GcCmdResponse")
{
handler(this, new PropertyChangedEventArgs("m_GmProtocol"));
}
//判断是否需要开启网络通信模块
if (propertyName == "m_GmExtmemXfer" || propertyName == "m_GmMacroCmd" ||
propertyName == "m_GmSystem" || propertyName == "m_GmMotionBlock" || propertyName == "m_GcCmdResponse")
{
handler(this, new PropertyChangedEventArgs("m_GmCmdHandler"));
}
//判断是否需要开启串口通信模块
if (propertyName == "m_GcDioAdtAdam"|| propertyName == "m_GcDioDamJy" || propertyName == "m_GcAmpGthd" ||
propertyName == "m_GcAmpMsb" || propertyName == "m_GcBc2Hnw" || propertyName == "m_GcDgSfj" || propertyName == "m_GcPlcMsbFx" ||
propertyName == "m_GcThmCnCar" || propertyName == "m_GcMtrMoonMSST5" || propertyName == "m_GcWeigherYH" || propertyName == "m_GcUpsSataC6k" ||
propertyName == "m_GcLsrKyIl" || propertyName == "m_GcLcMtdc")
{
handler(this, new PropertyChangedEventArgs("_GmSerial"));
}
}
}
}
}
======================================
IsChecked="{Binding m_GmMotionBlock, UpdateSourceTrigger=PropertyChanged}" 在Xaml中绑定CheckBox
Text="{Binding m_GcCmdResponse, UpdateSourceTrigger=PropertyChanged}" 在Xaml中绑定TextBox