[英]Silverlight databinding
好吧,我的代碼后面有這個代碼
Public Shared ReadOnly UsernameProperty As DependencyProperty = DependencyProperty.Register("Username", GetType(String), GetType(LoginControl), Nothing)
Public Property Username() As String
Get
Return CStr(MyBase.GetValue(UsernameProperty))
End Get
Set(ByVal value As String)
MyBase.SetValue(UsernameProperty, value)
End Set
End Property
然后我在同一頁面的xaml中有這個
<TextBlock Text="{Binding Path=Username}" Style="{StaticResource WelcomeTextStyle}"/>
但該文本塊似乎並未更新其值。
您將路徑設置為“用戶名”,但是綁定需要知道要在該對象上查找該對象的對象。 一種方法是將DataContext設置為LoginControl。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.