【发布时间】:2012-04-21 05:56:49
【问题描述】:
我正在尝试将 setter 值绑定到属性,但我不断收到灾难性错误 0x8000ffff
试过这个:
<ItemsControl.Style>
<Style TargetType="ContentPresenter">
<Setter Property="Grid.Row"
Value="{Binding GridRow}" />
<Setter Property="Grid.Column"
Value="{Binding GridColumn}" />
</Style>
</ItemsControl.Style>
然后这个:
<ItemsControl.Style>
<Style TargetType="ContentPresenter">
<Setter Property="Grid.Row"
Value="0" />
<Setter Property="Grid.Column"
Value="0" />
</Style>
</ItemsControl.Style>
我必须升级到 SL5 才能获得 TargetType。第二个示例删除了任何绑定尝试,但仍然“灾难性地”失败。
<ItemsControl.ItemsPanel> <ItemsPanelTemplate> <layout:MatrixGrid /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel>
我正在尝试在网格中创建一个数据矩阵(如其他人的示例所述)。
ItemsControl(在 Silverlight 中)没有 ItemContainerStyle 元素,所以我正在尝试这个,到目前为止还没有运气。
<ListBox.ItemsPanel> <ItemsPanelTemplate> <layout:MatrixGrid /> </ItemsPanelTemplate> </ListBox.ItemsPanel> <ListBox.ItemContainerStyle> <Style TargetType="ContentPresenter"> <Setter Property="Grid.Row" Value="{Binding GridRow}" /> <Setter Property="Grid.Column" Value="{Binding GridColumn}" /> </Style> </ListBox.ItemContainerStyle>
【问题讨论】:
-
你能说明你使用这种风格的背景吗?
-
嗨 ChrisF,我在 ItemsControl 中使用它
-
如果你的风格是
ItemsControl,为什么还要使用TargetType="ContentPresenter"? -
我在翻译中丢失了它,从一个具有 的 WPF 示例开始
标签: silverlight xaml binding