【问题标题】:Does Silverlight 4.0 support bindings in a style setter?Silverlight 4.0 是否支持样式设置器中的绑定?
【发布时间】:2011-03-06 13:01:32
【问题描述】:

我正在尝试将应用程序从 WPF 移植到 Silverlight,但它在一些非常简单的绑定上失败了。

我有以下简单的例子:

    <ListBox >
        <ListBox.ItemContainerStyle>
            <Style TargetType="ListBoxItem">
               <Setter Property="Canvas.Top" Value="{Binding X}"></Setter>
            </Style>
        </ListBox.ItemContainerStyle>
        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <Canvas></Canvas>
            </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
       </ListBox>

但是,Silverlight 解析会崩溃。 但是,如果我将绑定替换为常量,则一切正常:

    <ListBox >
        <ListBox.ItemContainerStyle>
            <Style TargetType="ListBoxItem">
               <Setter Property="Canvas.Top" Value="3"></Setter>
            </Style>
        </ListBox.ItemContainerStyle>
        <ListBox.ItemsPanel>
            <ItemsPanelTemplate>
                <Canvas></Canvas>
            </ItemsPanelTemplate>
        </ListBox.ItemsPanel>
        </ListBox>

这是为什么?

【问题讨论】:

    标签: silverlight data-binding silverlight-4.0


    【解决方案1】:

    不,它不提供(仍然)

    【讨论】:

      【解决方案2】:
      猜你喜欢
      • 2010-09-28
      • 1970-01-01
      • 1970-01-01
      • 2012-10-08
      • 2017-01-30
      • 2010-11-26
      • 2012-04-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多