【发布时间】:2009-03-18 12:25:38
【问题描述】:
假设我们有这样的控制:
public partial class MyUserControl : UserControl
{
public MyUserControl() {
InitializeComponent();
}
public string Foo { get; set; }
}
如何在 MyUserControl.xaml 中以声明方式设置“Foo”属性值?
<UserControl x:Class="Test.MyUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!-- Looking for some thing like this -->
<Foo>Hola</Foo>
</UserControl>
更清楚一点:如何在 XAML 中为代码隐藏中定义的属性设置值。
【问题讨论】:
标签: wpf xaml user-controls