简体   繁体   English

如何从 XAML 获取实例 UserControl?

[英]How to get an instance UserControl from XAML?

In XAML, I put an user control.在 XAML 中,我放置了一个用户控件。 I'd like to get that instance in initialize component in C# code.我想在 C# 代码中的初始化组件中获取该实例。

Use the x:Name property in the XAML, and you will be able to reference it by that name from the code behind.使用 XAML 中的x:Name属性,您将能够从后面的代码中通过该名称引用它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从XAML设置WPF usercontrol属性? - How to set a WPF usercontrol property from XAML? 无法从aspx页面获取用户控件的实例 - Cannot get instance of usercontrol from aspx page 如何从UserControl实例创建DataTemplate? - How to create DataTemplate from UserControl instance? 如何从xaml访问UserControl中的按钮? - How do I Access Buttons inside a UserControl from xaml? 如何从 Button 动态创建的 UserControl 实例进入 event_Click? - How can I get inside event_Click from instance of UserControl that created dynamicly from Button? 如何在网格中放置一个 XAML 用户控件 - How to place an XAML usercontrol in a grid 如何同时单击位于一个MainWindow(C#/ Xaml)中的另一个UserControl来显示/调用另一个UserControl - How to diplay/call an UserControl from another UserControl at click both situated in one MainWindow (C#/Xaml) 如何将 MainWindow 上的自定义属性获取到 UserControl(来自 UserControl 库/DLL)? - How to get custom property on MainWindow into a UserControl (from UserControl library/DLL)? 从同一页面上的其他UserControl使用C#XAML访问UserControl - c# XAML Access UserControl from other UserControl on same page 限制用户控制超出画布XAML - Restricting usercontrol from moving beyond the canvas xaml
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM