在XAML绑定用户控件 [英] Binding UserControl in XAML
本文介绍了在XAML绑定用户控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想结合我在一类财产创建一个用户控件。我不能想出如何证明它在XAML。
例如:
公共类MainWindowViewModel:ViewModelBase
{
公众用户控件{的MyUserControl获得;组; }; 公共MainWindowViewModel()
:基地()
{
_myUserControl =新WelcomePageView()); }
}
在XAML:
<窗口C:类=..
。
。
。
/>
< ???? {结合}的MyUserControl GT&;
< /窗GT;
解决方案
尝试
< ContentControl中CONTENT ={结合your_usercontrol}/>
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>
解决方案
Try
<ContentControl Content="{Binding your_usercontrol}" />
这篇关于在XAML绑定用户控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文