【发布时间】:2010-07-16 13:26:07
【问题描述】:
看来这应该很简单...
我有一个用户控件,我将在选项卡控件的几个选项卡上使用它。我希望同步用户控件的所有实例。
在我的用户控件中,我有一个字符串列表:
public static List<string> fonts = new List<string>() { "Arial", "Courier" };
还有一个列表框:
<ListBox x:Name="fontList" ItemsSource="{Binding Path=fonts}" />
但是,列表框永远不会被填充。
在搜索示例代码时,我似乎在几个示例中看到了这个实现,但我无法让它工作。
感谢您的任何提示...
已根据 AWJ 的建议更新,但仍无法正常工作:
MainPage.xaml.cs:
public partial class MainPage : UserControl
{
public static List<string> _fonts
= new List<string>() { "Arial", "Courier" };
public List<string> Fonts { get { return _fonts; } }
}
在 TestGroup.xaml 中:
<ListBox x:Name="fontList1" ItemsSource="{Binding Parent.Fonts, ElementName=LayoutRoot}" Margin="3" />
【问题讨论】:
标签: silverlight data-binding silverlight-4.0