样式中的 Silverlight 绑定问题



我正在尝试将 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才能获得目标类型。第二个示例删除了任何绑定尝试,但仍然"灾难性地"失败。

<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>

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

最新更新