【问题标题】:Silverlight {Binding Key} - Please refresh my memory?Silverlight {Binding Key} - 请刷新我的记忆?
【发布时间】:2011-10-06 20:59:07
【问题描述】:

我敢肯定这很简单,但我到底错过了什么?有人能告诉我Text="{Binding Key}" 中的关键字“Key”指的是什么吗?我知道我以前了解过它,但我似乎不记得了。我了解数据绑定的工作原理,只是停留在这个特定问题上。

 <DataTemplate x:Key="groupItemHeader">
            <Border Background="{StaticResource PhoneAccentBrush}"
                    Width="432" Height="62"
                    Margin="6" Padding="12,0,0,6">
                <TextBlock Text="{Binding Key}" 
                           Foreground="#FFFFFF" FontSize="26.667"
                           HorizontalAlignment="Left"
                           VerticalAlignment="Bottom"
                           FontFamily="{StaticResource PhoneFontFamilySemiBold}"/>
                <Border.Projection>
                    <PlaneProjection RotationX="-60"/>
                </Border.Projection>
            </Border>
        </DataTemplate>

【问题讨论】:

    标签: silverlight binding


    【解决方案1】:

    {Binding Key}{Binding Path=Key} 的简写。这将返回当前DataContextKey 属性的值。

    【讨论】:

    • 所以“Key”肯定是绑定源对象的属性?
    • 否,Source 尚未在 Binding 上指定。在这种情况下,DataContext 是使用 DataTemplate 的对象,因此 Key 属性必须出现在该对象上
    • 知道了。感谢您的澄清。
    猜你喜欢
    • 2019-11-29
    • 2020-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-25
    • 1970-01-01
    • 1970-01-01
    • 2015-05-05
    相关资源
    最近更新 更多