【发布时间】:2026-01-22 07:45:02
【问题描述】:
您好,我的用户控件中有 contentControl。我正在将样式应用于由 TextBlock 和 ListBox 组成的 contentControl。我将 textBlock 的文本绑定到 CategoryName(来自控件的标记)。我想将类别的子项绑定到 listBox。我已将 ContentControl 的 dataContext 属性设置为子项 []。现在如何将这些子项绑定到资源中的列表框。
在用户控件的加载事件中 面板 pnl = 作为面板的发送者; 类别类别 = 面板。标记为类别; Items[] items = GetChildItemsByCategoryId(category.CategoryID); mainContent.DataContext = 项目;
【问题讨论】:
标签: silverlight