本文整理汇总了C#中System.Windows.Controls.UserControl.FindName方法的典型用法代码示例。如果您正苦于以下问题:C# UserControl.FindName方法的具体用法?C# UserControl.FindName怎么用?C# UserControl.FindName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Controls.UserControl
的用法示例。
在下文中一共展示了UserControl.FindName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: showerror
public void showerror(Hashtable errors,UserControl a)
{
foreach (DictionaryEntry error in errors)
{
String check = error.Key.ToString();
if (error.Value.ToString() == "text")
{
if (check.Substring(check.Length - 1, 1) != "!" )
{
TextBox e = (TextBox)a.FindName("txt" + check);
e.BorderBrush = Brushes.Red;
}
else
{
TextBox e = (TextBox)a.FindName("txt"+check.Substring(0,check.Length-1));
e.BorderBrush = Brushes.SkyBlue;
}
}
if (error.Value.ToString() == "password")
{
if (check.Substring(check.Length - 1, 1) != "!")
{
PasswordBox e = (PasswordBox)a.FindName("pb" + error.Key);
e.BorderBrush = Brushes.Red;
}
else
{
PasswordBox e = (PasswordBox)a.FindName("pb" + check.Substring(0, check.Length - 1));
e.ClearValue(TextBox.BorderBrushProperty);
e.Password = "";
}
}
if (error.Value.ToString() == "duplicate")
{
TextBox e = (TextBox)a.FindName("txt" + check.Substring(0, check.Length - 1));
e.BorderBrush = Brushes.Red;
}
}
}
示例2: DragSourcePieMenuPreviewMouseLeftButtonDown
public void DragSourcePieMenuPreviewMouseLeftButtonDown(UserControl diagramUserControl, StylusEventArgs e)
{
try
{
_topUserControl = diagramUserControl;
_initialMousePosition = e.GetPosition(_topUserControl);
_adornerLayer = (Canvas)_topUserControl.FindName("adornerLayer");
_dropTarget = (UIElement)_topUserControl.FindName("inkCanvas");
}
catch (Exception exc)
{
Console.WriteLine("Exception in DragDropHelper: " + exc.InnerException.ToString());
}
}
示例3: DragSource_UserControl_PreviewMouseLeftButtonDown
public void DragSource_UserControl_PreviewMouseLeftButtonDown(UserControl diagramUserControl, object sender, MouseButtonEventArgs e)
{
try
{
_topUserControl = diagramUserControl;
_initialMousePosition = e.GetPosition(_topUserControl);
_adornerLayer = (Canvas)_topUserControl.FindName("adornerLayer");
_dropTarget = (UIElement)_topUserControl.FindName("inkCanvas");
_draggedData = (sender as FrameworkElement).DataContext;
}
catch (Exception exc)
{
Console.WriteLine("Exception in DragDropHelper: " + exc.InnerException.ToString());
}
}
示例4: ReadSampleCount
private int ReadSampleCount(UserControl ControlUI)
{
var container = ControlUI.FindName("txtSampleCnt");
TextBox txtSampleCnt = (TextBox)container;
if (txtSampleCnt == null)
throw new Exception("无法找到样本数textbox!");
if (txtSampleCnt.Text == "")
{
throw new Exception("请先设置样本数!");
}
int val = int.Parse(txtSampleCnt.Text);
if (val <= 0)
{
throw new Exception("样本数必须大于0!");
}
return val;
}