【问题标题】:Silverlight sdk:DataGridCell Template with TextBox - the Binding?Silverlight sdk:DataGridCell 模板与 TextBox - 绑定?
【发布时间】:2011-11-21 23:33:01
【问题描述】:

我在 sdk:DataGridCell 模板中寻找绑定 TextBlock 的正确方法; WPF 中的方式 - Text={Binding} 不起作用。

<Style TargetType="sdk:DataGridCell">
<Setter Property="Template">
<Setter.Value>
    <ControlTemplate TargetType="ContentControl">
        <Grid>
            <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="MouseOver">
            </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
        <Border Background="{x:Null}">
            <TextBlock Text="{Binding}" Foreground="Black"/>
        </Border>
        </Grid>
    </ControlTemplate>
    </Setter.Value>
</Setter>

Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content.Text}" 也不起作用。

还有其他想法吗?非常感谢。

【问题讨论】:

    标签: silverlight templates binding datagrid


    【解决方案1】:

    当您需要离开数据网格以获取父数据上下文时,请在此处查看我对类似问题的回答。 :

    Silverlight - Access the Layout Grid's DataContext in a DataGrid CellTemplate's DataTemplate?

    希望这会有所帮助。

    【讨论】:

      猜你喜欢
      • 2011-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多