【发布时间】:2010-10-16 05:08:05
【问题描述】:
我正在 Silverlight 中构建一个自定义 ItemsControl(除其他外),它允许项目在运行时水平或垂直显示。如何将 ItemsPanel 的 Orientation 属性绑定到我的父控件的 Orientation 属性?我尝试使用 TemplateBinding(在 ControlTemplate 中工作),但在 ItemsPanelTemplate 中似乎不起作用,我做错了什么吗?
<Style TargetType="CustomItemsControl">
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<StackPanel Orientation="{TemplateBinding Orientation}" />
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
</Style>
【问题讨论】:
标签: silverlight controls