我有一个 Form1 类的形式和一个 WPF 用户控件(在 ElementHost 内)。如何从该控件的代码隐藏中获取 Form1 对象?
这是代码:
/// <summary>
/// Interaction logic for UserControl1.xaml
/// </summary>
public partial class UserControl1 : UserControl
{
public UserControl1()
{
InitializeComponent();
}
private void Btn_Click(object sender, RoutedEventArgs e)
{
// I'd like to access the form here
}
}