本文整理汇总了C#中System.Windows.Window.FindName方法的典型用法代码示例。如果您正苦于以下问题:C# Window.FindName方法的具体用法?C# Window.FindName怎么用?C# Window.FindName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Window
的用法示例。
在下文中一共展示了Window.FindName方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MainWindowViewModel
public MainWindowViewModel(Window window)
{
_window = window;
_console = (TextBox)window.FindName("_consoleBuffer");
_messages = (TextBox)window.FindName("_messageBuffer");
_scheduler = TaskScheduler.FromCurrentSynchronizationContext();
DiscoverTests = new RelayCommand(ExecuteDiscoverTests, CanExecuteDiscoverTests);
SelectDNX = new RelayCommand(ExecuteSelectDNX, CanExecuteSelectDNX);
SelectProject = new RelayCommand(ExecuteSelectProject, CanExecuteSelectProject);
StartTestHost = new RelayCommand(ExecuteStartTestHost, CanExecuteStartTestHost);
StopTestHost = new RelayCommand(ExecuteStopTestHost, CanExecuteStopTestHost);
RunAllTests = new RelayCommand(ExecuteRunAllTests, CanExecuteRunAllTests);
RunSelectedTests = new RelayCommand(ExecuteRunSelectedTests, CanExecuteRunSelectedTests);
}
示例2: OnLoaded
internal void OnLoaded(Window win)
{
this.Clear();
if (!string.IsNullOrEmpty(this.captionInfo.IncludeName))
{
this.captionInfo.IncludeElement = win.FindName(this.captionInfo.IncludeName) as FrameworkElement;
}
if ((this.captionInfo.ExIncludesName != null) && (this.captionInfo.ExIncludesName.Length > 0))
{
this.captionInfo.ExIncludesElement = new FrameworkElement[this.captionInfo.ExIncludesName.Length];
for (int i = 0; i < this.captionInfo.ExIncludesName.Length; i++)
{
this.captionInfo.ExIncludesElement[i] = win.FindName(this.captionInfo.ExIncludesName[i]) as FrameworkElement;
}
}
}
示例3: Cancel
private void Cancel(Window window)
{
Username = "";
Password = "";
var usernameTextBox = (TextBox)window.FindName("txtbname");
if (usernameTextBox!=null)
PutFocusOnControl(usernameTextBox);
}
示例4: AddSample
private void AddSample(Window parent, UserControl ctrl)
{
Grid.SetColumn(ctrl, 1);
Grid.SetRow(ctrl, 1);
ctrl.ClearValue(UserControl.WidthProperty);
ctrl.ClearValue(UserControl.HeightProperty);
var g = parent.FindName("content") as Grid;
g.Children.Add(ctrl);
}
示例5: NavigationViewController
public NavigationViewController(Window canvas, Grid navigationBar)
{
this.canvas = canvas;
this.canvasGrid = canvas.FindName("Canvas") as Grid;
this.navigationBar = navigationBar;
this.leftButton = (Label)navigationBar.FindName("LeftButtonLabel");
this.rightButton = (Label)navigationBar.FindName("RightButtonLabel");
this.title = (Label)navigationBar.FindName("Title");
((StackPanel)(navigationBar.FindName("LeftButton"))).MouseDown += leftButton_MouseDown;
((StackPanel)(navigationBar.FindName("RightButton"))).MouseDown += rightButton_MouseDown;
}
示例6: TrashCanPopupManager
/// <summary>
/// Initializing constructor
/// </summary>
/// <param name="parent">Reference to a parent window</param>
public TrashCanPopupManager( Window parent )
{
_trashCan = parent.FindName( "TrashCanPopup" ) as Popup;
_trashIcon = parent.FindName( "TrashIconRect" ) as FrameworkElement;
if( _trashCan != null )
{
DragHelper.DragStarted += OnGlobalDragStarted;
DragHelper.DragComplete += OnGlobalDragComplete;
var dropHelper = new DropHelper( _trashCan );
dropHelper.QueryDragDataValid += OnTrashCanDragQueryDataValid;
dropHelper.TargetDrop += OnTrashCanDrop;
}
if( _trashIcon != null )
{
_trashIcon.RenderTransform = new ScaleTransform( 1.0, 1.0 );
_trashIcon.RenderTransformOrigin = new Point( 0.5, 0.9 );
}
}
示例7: MapsGraphicalInterface
public MapsGraphicalInterface(Window selfHandler, ListBox mapListOuter, TextBlock mapNameOuter, TextBlock mapStateOuter, TextBlock mapDateAddedOuter, string resourcesPrefix)
{
this.MapList = mapListOuter;
this.MapName = mapNameOuter;
this.MapState = mapStateOuter;
this.MapDateAdded = mapDateAddedOuter;
foreach (resourseTypes type in Enum.GetValues(typeof(resourseTypes)))
{
this.TBS[type] = (TextBlock)selfHandler.FindName(resourcesPrefix + type.ToString());
}
// set null titles up
this.setSelectedMap(null);
}
示例8: removeControl
public static Grid removeControl(Window Parent)
{
/*
*
* WPF Page를 제거하고 해당 페이지가 들어있던 Grid를 반환한다.
*
* */
try
{
Grid MainGrid = (Grid)Parent.FindName("MainGrid");
MainGrid.Children.Remove(MainGrid.Children[0]);
return MainGrid;
}
catch (Exception)
{
return null;
}
}
示例9: getGrid
public static Grid getGrid(Window Parent)
{
return (Grid)Parent.FindName("MainGrid");
}
示例10: DragSource_PreviewMouseLeftButtonDown
private void DragSource_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
try
{
Visual visual = e.OriginalSource as Visual;
_topWindow = (Window)DragDropHelper.FindAncestor(typeof(Window), visual);
if (!_topWindow.IsActive)
return;
_initialMousePosition = e.GetPosition(_topWindow);
string adornerLayerName = GetAdornerLayer(sender as DependencyObject);
_adornerLayer = (Canvas)_topWindow.FindName(adornerLayerName);
string dropTargetName = GetDropTarget(sender as DependencyObject);
_dropTarget = (UIElement)_topWindow.FindName(dropTargetName);
_draggedData = (sender as FrameworkElement).DataContext;
}
catch (Exception exc)
{
Console.WriteLine("Exception in DragDropHelper: " + exc.InnerException.ToString());
}
}
示例11: SetTranslation
private void SetTranslation(Window varControl, string msg)
{
if (varControl.Dispatcher.CheckAccess())
{
RichTextBox txtTranslation = varControl.FindName("txtTranslation") as RichTextBox;
txtTranslation.Document = new FlowDocument(new Paragraph(new Run(msg)));
txtTranslation.Foreground = _fontColor;
txtTranslation.Focus();
}
else
{
varControl.Dispatcher.Invoke(new Action<Window, string>((c, m) => SetTranslation(varControl, msg)), new object[] { varControl, msg });
}
}
示例12: WpfTextTraceListener
public WpfTextTraceListener(string name)
: base(name)
{
ownerWindow = Application.Current.Windows.OfType<Window>().SingleOrDefault(x => x.IsActive);
output = (TextBlock)ownerWindow.FindName("Status");
}