Wpf 在XAML中绑定UserControl

Wpf 在XAML中绑定UserControl,wpf,binding,user-controls,Wpf,Binding,User Controls,我试图将在类中创建的userControl绑定为属性。我不知道如何在XAML中显示它 例如: public class MainWindowViewModel : ViewModelBase { public UserControl myUserControl { get; set; }; public MainWindowViewModel() : base() { _myUserControl = new WelcomePageVie

我试图将在类中创建的userControl绑定为属性。我不知道如何在XAML中显示它

例如:

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

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

    }
}
在XAML中:

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

试一试


试试看



这不起作用,myViewUserControl不可见。试图添加的UserControl有ViewPort3d元素,它需要任何东西才能显示吗..好吧,真丢脸!我刚刚注意到宽度和高度值是自动的。所以他们可以降低能见度。行得通……)这不起作用,myViewUserControl不可见。试图添加的UserControl有ViewPort3d元素,它需要任何东西才能显示吗..好吧,真丢脸!我刚刚注意到宽度和高度值是自动的。所以他们可以降低能见度。行得通……)
<ContentControl Content="{Binding your_usercontrol}" />