【问题标题】:WP7 custom UserControl bindingWP7 自定义 UserControl 绑定
【发布时间】:2012-07-10 05:24:51
【问题描述】:

我创建简单的水印文本框

<Grid x:Name="LayoutRoot">
    <Grid>
        <TextBox Style="{StaticResource TextBoxStyle1}" Name="hint" TextWrapping="Wrap" FontSize="20" IsHitTestVisible="False" />
        <TextBox Name="text" TextWrapping="Wrap" Opacity="0" LostFocus="TextLostFocus" GotFocus="TextGotFocus" />
    </Grid>
</Grid>

定义属性提示

public String Hint { get { return hint.Text; } 设置 { 提示。文本 = 值; } }

但我不能在 Hiht 属性上使用数据绑定。应用程序本地化为两种语言并提示 TextBox 必须以正确的语言显示文本。

【问题讨论】:

  • 您能否更新您的示例以显示您尝试绑定到 Hint 属性的位置?

标签: windows-phone-7 binding user-controls


【解决方案1】:

您需要将您的属性 (Hint) 声明为依赖属性以支持绑定到它。参见例如这个在线dependency property declaration creator tool

【讨论】:

    猜你喜欢
    • 2011-10-27
    • 1970-01-01
    • 2010-12-04
    • 2013-01-20
    • 1970-01-01
    • 2020-06-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多