0

我正在尝试将设置器值绑定到属性,但我不断收到灾难性错误 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>
4

1 回答 1

0

Style.TargetType属性设置样式所针对的类型。尝试将其设置为ItemsControl,这可能是它下降的原因。

于 2012-04-09T06:22:08.523 回答