簡體   English   中英

WP7自定義UserControl綁定

[英]WP7 custom UserControl binding

我創建了簡單的帶水印的TextBox

<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; }設置{hint.Text = value; }}

但是我不能對Hiht屬性使用數據綁定。 本地化為兩種語言的應用程序和提示TextBox必須以正確的語言顯示文本。

您需要將屬性(提示)聲明為依賴項屬性,以支持對其進行綁定。 參見例如此在線依賴項屬性聲明創建器工具

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM