简体   繁体   中英

How do i call user control in WPF from main window?

lately i'm working on WPF UserControl ,i'm kind first time using UserControl after WPF window. I have created WPF Application, it has Window called " MainWindow ". MAinWindow have Button named ' Technology '. I have also created UserControl named ' TechnologyUserControl '.I want to show ' TechnologyUserControl ' after clicking on button ' Technology '. Can anybody help me .. Thanks..

I was going to downvote you or comment: 'What have you tried?', but then again:

You need to instantiate the UserControl, set its DataContext and add it to a parent view. You can do this either with markup (XAML), or in code.

如果您的TechnologyUserControl首先设置为“ 隐藏” ,请在Technology上创建一个click事件并将其放置在其中:

TechnologyUserControl.Visibility = System.Windows.Visibility.Visible;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM