C# WPF 之 遍历子控件
/// <summary>
/// 检查非空字段
/// </summary>
/// <param name="IsOk"></param>
/// <param name="textboxes"></param>
private void CheckTextBoxNotNull(ref bool IsOk, params TextBox[] textboxes)
{
foreach (TextBox txtBox in textboxes)
{
txtBox.Background = Brushes.White;
if (txtBox.Text.Length <= )
{
IsOk = false;
txtBox.Background = Brushes.Red;
}
else
{
txtBox.Background = null;
}
}
}
/// <summary>
/// 设置控件
/// </summary>
/// <param name="IsEn"></param>
/// <param name="IsNull"></param>
private void SetControl(bool IsEn ,bool IsNull)
{
foreach (UIElement c in grd_UserInfo.Children)
{
if (c is TextBox)
{
c.IsEnabled = IsEn;
if (IsNull)
{
((TextBox)c).Text = "";
}
}
if (c is ComboBox)
{
c.IsEnabled = IsEn;
if (IsNull)
{
((ComboBox)c).SelectedIndex = -;
}
}
if (c is DatePicker)
{
c.IsEnabled = IsEn;
if (IsNull)
{
((DatePicker)c).SelectedDate = null;
}
}
}
btn_ChoosePhoto.IsEnabled = IsEn;
}
/// <summary>
/// 验证邮箱输入是否合法
/// </summary>
/// <param name="strIn"></param>
/// <returns></returns>
private bool IsValidEmail(string strIn)
{
return Regex.IsMatch(strIn, @"^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$");
}
C# WPF 之 遍历子控件的更多相关文章
- c# 遍历子控件,比如Form下的group,或者panel
方法很好用.目的是遍历所有容器的子控件... 方法1private void GetControl(Control.ControlCollection ctc, ref int checkNull) ...
- WPF silverlight获取子控件(获取DataTemplate里的子控件)
public static class VisualTreeExtensions { /// <summary> /// 获取父节点控件 /// </summary> /// ...
- C#遍历窗体控件(原文出自http://www.liangshunet.com/ca/201403/286434593.htm)
一.C#遍历窗体控件 主要遍历属于窗体(Form)的控件(Controls),假如窗体中有 Panel.Button 和 TextBox 控件,遍历代码如下: /// <summary> ...
- C# WPF 父控件通过使用可视化树找到子控件
在我们使用WPF设计前台界面时,经常会重写数据模板,或者把控件放到数据模板里.但是一旦将控件放到数据模板中,在后台就没有办法通过控件的名字来获取它了,更没办法对它进行操作(例如,隐藏,改变控件的某个值 ...
- WPF加载Winform窗体时 报错:子控件不能为顶级窗体
一.wpf项目中引用WindowsFormsIntegration和System.Windows.Forms 二.Form1.Designer.cs 的 partial class Form1 设置为 ...
- WPF布局控件与子控件的HorizontalAlignment/VerticalAlignment属性之间的关系
WPF布局控件与子控件的HorizontalAlignment/VerticalAlignment属性之间的关系: 1.Canvas/WrapPanel控件: 其子控件的HorizontalAlign ...
- 【WPF】查找父/子控件(元素、节点)
整理一下项目中常用的找控件功能,包括找父/子控件.找到所有同类型子控件(比如ListBox找到所有Item). using System; using System.Collections.Gener ...
- WPF通过不透明蒙板切割显示子控件
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明.本文链接:https://blog.csdn.net/Backspace110/article/ ...
- wpf 寻找某个控件下的子控件
/// <summary> /// 寻找某个控件下的子控件 /// </summary> /// <typeparam name="ChildType" ...
随机推荐
- Protocol Buffers(Protobuf)开发者指南---概览
Protocol Buffers(Protobuf)开发者指南---概览 欢迎来到protocol buffers的开发者指南文档,protocol buffers是一个与编程语言无关‘.系统平台无关 ...
- 三大框架ssh
一.hibernate a.实体类+映射 b.lib hibernate包+oracle包(oracle安装里找) 映射:从类入手class+属性 a.映射的头文件在:hibernate3.jar- ...
- struts+spring action应配置为scope="prototype"
truts+spring action应配置为scope="prototype" <bean id="personAction" scope=" ...
- Java调用动态库方法说明-最详细
Java不能直接调用由c或者c++写得dll(TF_ID.dll),所以只能采用jni得方法,一步一步生成符合规范得dll文件(假设叫FANGJIAN.dll),在FANGJIAN.dll这个文件里来 ...
- unity3D 搞定任意ios插件
原地址:http://www.cnblogs.com/U-tansuo/archive/2012/11/22/unity_ios-plugin.html 说起unity调ios插件,好多淫比较头痛,探 ...
- 如何用rake tasks 生成migration对应的sql
how-to-use-rake-tasks-to-generate-migration-sql Rakefile文件里有load_tasks的方法 http://api.rubyonrails.org ...
- DICOM:DICOM标准学习路线图(初稿)
题记: DICOM医学图像处理专栏撰写已有两个年头,积累了近百篇文章.起初只是用于记录自己科研.工作中遇到的疑难问题,专注于图像处理(主要是医学图像,这也正是专栏名称最初的由来):后来逐渐延伸到了DI ...
- 栈应用hanoi
/* 课本p54页*/ #include<stdio.h> #include <iostream> using namespace std; void move(int n, ...
- redhat 6 / centos 6 搭建Django环境
1)首先 安装的时候 到 选择安装那些包的时候 把 编译环境和开发的包 那块全部打上勾 2)系统虽然自带Python安装包,但是版本比较低.所以推荐自行进行tar包编译安装比较新的 https:// ...
- javascript 重写已有的方法
现在有一个需求,需要重写方法,比如方法名为a,但是在方法内部,需要用到原来的方法,怎么办? 最直接的办法是: var b = a; window.a = function(args){ a.call( ...