Binding UserControl in XAML

2019-09-03 09:28发布

I am trying to bind a userControl that I create in a class as property. I couldnt figure out how to show it in XAML.

Example:

public class MainWindowViewModel : ViewModelBase
{
    public UserControl myUserControl { get; set; };

    public MainWindowViewModel()
        : base()
    {
        _myUserControl = new WelcomePageView());

    }
}

In XAML:

<Window c:Class=".."
   .
   .
   .
 />
<???? {Binding myUserControl}>
</Window>

1条回答
走好不送
2楼-- · 2019-09-03 10:23

Try

<ContentControl Content="{Binding your_usercontrol}" />
查看更多
登录 后发表回答