load a specified user control and its code behind on demand

jennyliu835 221 Reputation points
2020-10-05T03:58:17.937+00:00

Hi Peter + Daisy,
As far as I can understand, the code behind of a specified user control would fail
the following code:

(UserControl)XamlReader.Load(new FileStream(_userControlFilePath, FileMode.Open));

Is there a way to load a specified user control and its code behind, just as we do with a specified page? For example,

 NavigationService NS = fm.NavigationService;
 NS.Navigate(new Uri("pages/Page2.xaml", UriKind.Relative));

Thanks.

Windows Presentation Foundation
Windows Presentation Foundation
A part of the .NET Framework that provides a unified programming model for building line-of-business desktop applications on Windows.
2,706 questions
{count} votes